Qt - TableView with categories - c++

I am looking to replicate the look of the TableView presented in this picture using Qt. The one in the picture looks to be created with Windows Forms. The main part I'm wondering about is how the different items have different categories kind of (with each section having a header).
Is it possible to do this in a Qt TableView, or do I need to use a TreeView?

Related

Hierarchical Listview QML

I want to display hierarchical Data with a QML-Listview. This means that I have different Cpp datamodels, that have the following structure:
Section 1
Subsection 1
Item
Item
Subsection 2
Item
Section 2
The number of subsections is different in every model, so that I'm looking for a general solution to display that data in a flat list like that:
Section 1
Subsection 1
Item
Item
...
I'm using Qt 4.8.2 with Qt Quick 1.1.
What I figured out till now:
The QML ListView cannot display hierarchical listmodels
There are different solutions to display tree-structured extendable lists with multiple Listviews, but that's too complex for my models
I can make my model flat by using a Abstract-Class insert different Object types in a flat list, but that would be a lot of work, cause I had to insert lots of loops
Till now I found one solution provided by blackberry cascades, but I can't use it because I have to run my application on Embedded Linux:
Cascades Vegetables Data Model
At this moment I'm thinking about to write my own ListView with Cpp, but I would really like to avoid that because It will be a lot of work to implement that.
I'm new here at stackoverflow, so please let me know if I have to give you more informations.
Thank's in advance.
Quperman
EDIT 05.08.2014:
Temporary Solution:
Since It seems to be hard work for me to implement my own Cpp TreeView, I found another easier solution:
I created an abstract class AbstractItem with an attribute ItemType (enum), that has the following values:
Item
Section
Subsection
...
What I now do is the following:
I inherit my Section and Item classes from my new class AbstractItem. Now I put QList into my QAbstractListModel and appended the items, sections, subsections...
I can now provide different data in header and item by implementing the data() function with a switch over ItemType. depending on the ItemType I can do a reinterpret_cast to access the data.
Now I have a flat hierarchy that works for me. Sadly I can't use the class hierarchy, but at this moment it seems to be the fastest solution.
15th May 2015 We got beta version of Qt 5.5. See its features. Take a deep breath... Now you can use TreeView component in QML!
Take a look at snapshot for Qt 5.5 documentation.

Creating tabbed document interfaces in Qt Designer?

I am trying to write a program that will use a tabbed document interface (TDI) like seen in Notepad++ or most web browsers. I know how to build GUIs using Qt Designer, and code in Qt C++ (after a few days of playing around).
I have created an example of what each page widget will look like using Designer, and now I want to add the ability to create and testroy tabs at runtime, each containing a unique instance of the page widget. However, I have no idea how to do this without adding a class that extends QWidget, and building the page widget with code. I could go down this route, but I'm sure there must be a better way of creating a TDI; but I can't find any tutorials or examples of how to do this.
Does anyone have any suggestions?
For creating tab interfaces you should look into QTabWidget.
It is a container widget included in Qt Designer which automatically handles operations on tabs. It has several build in methods for manipulating its tabs and theirs contents.
Each page of QTabWidget is handled separately and can have different layouts and functionality.
If you want to include several different objects to one page assign a layout to it and then assign the objects to the layout.

how to create ms-access like continuous subforms (widgets) in Qt?

I'm thinking of porting my access application to Qt. I am interested to learn how to do continouos subforms, sub custom widgets for presenting/editing/inserting data from recordset in a verically scrollable non datagrid fashion. Meaning I could put button, label, combo, lineEdit... whatever, for every record.
I like QTableView and delegates. I just don't know if it could be modified to fully emulate access subform.
Sidequestion(maybe the same answer)... how do they DO those continuous forms in access under the hood.
thanks
... not real application data in that example recordset
Qt MVC is probably the best/easiest answer for your question ( http://qt-project.org/doc/qt-4.8/model-view-programming.html ), and with QTableView you should be able to achieve what you want.
Another solution could be: if you have a fix set of column items in every row you could simply design a QWidget with the contents of the row and paste your items (rows) into a QVerticalLayout.
Although I would sugget to try with MVC because that's the preferred way and in this case you could even port it to use QML UI if you want (while you can use the same data classes for the 'backend'). QML is definitely the best approach for (even slightly) animated UIs, and it's mature enough to use it already (it's part of Qt 4.8 and will be the 'star' of Qt 5).

Creating a listbox-like control in QT C++

I am a beginner at QT and I have been trying to port a GUI project over from raw Win32 to QT. Only problem is I cannot find the name for some controls in the QT framework such as the pictured one below.
I believe it is called a listbox in C# and C++ and I used some code to put the title bar up at the top containing "Update, Version, Size, Date". What would this translate to in QT? I have tried the tableview from QT but it only succeeds in making a Microsoft Excel type box with rows and columns, my goal is only to get vertical columns with a title at the top. Thank you!
That's not a ListBox control, that's a ListView control.
Not sure what Qt calls it, but since they prefix everything with a Q, I'd imagine it's QListView.
The ListView is like a super-duper ListBox that also has a column header attached to it when you set it to display in "Details" view.
QListBox was deprecated in Qt 4, and was replaced by QListView.
For the type of multi-column control pictured, QTreeWidget should work.

Does MFC have a built in grid control?

First what I want: The ability to display a grid with multiple columns, each cell having a custom render callback. So you might use such a control to display your inventory in a game, or something like the behaviour in Google Chrome where it shows a grid of popular pages you visit.
I've been playing with CListCtrl and while I can get custom rendering ability on each item, I can't get it work with columns - having say 3 items per row. The control has column-related methods but I think these are specifically for the built-in functionality where different attributes of an item are shown automatically in each column... not for providing a generic grid control.
So, does such functionality exist in MFC? If not then I wonder if the easiest approach is for me to actually insert each of the rows as an Item... and then the custom rendering draws the multiple cells in the row, I could also do custom UI to support clicking on the cells.
But what I really want is to be able to create a custom control, and add this as an item to a list - like in Flex for instance - so I/O etc is automatically handled.
Any advice/information welcome...
Dundas has thrown some of its (excellent) components in the public domain. Their Ultimate Grid is available on CodeProject.
I'm not aware of a built-in control, but I think you should take a look at this.
The article is describing in detail the functionality of a fully featured MFC grid control, derived from CWnd, for displaying tabular data.
YOUR_LIST_CONTROL.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_INFOTIP|LVS_EX_GRIDLINES);
I think it will help you (SetExtendedStyle).
I suggest this one:
https://code.google.com/p/cgridlistctrlex/
very complete