I've been searching docs and two books regarind adding custom structore to QStandardItem, however, I did not find it. I do not know how to continue, please help ... Does anyone has example?
I've been searching docs and two books regarind adding custom structore to QStandardItem, however, I did not find it. I do not know how to continue, please help ... Does anyone has example?
Qt 5.3 Opensource & Creator 3.1.2
QStandardItem docs, section "Subclassing".
MarkoSan (11th April 2008)
I've read it, wysota, but I still do not know how to integrate my struct into subclassed QStandardItem. Here is what I've done so far (it is very little), I really would need some deeper help. The header:Implementation:Qt Code:
#ifndef CSHOPPINGCARTITEM_H_ #define CSHOPPINGCARTITEM_H_ // qt includes #include <QStandardItem> static const int STRUCT_ORDER_TYPE=1001; { public: int type() const; }; #endif /*CSHOPPINGCARTITEM_H_*/To copy to clipboard, switch view to plain text modeWhere do I put my struct?!Qt Code:
#include "CShoppingCartItem.h" { } int CShoppingCartItem::type() const { return STRUCT_ORDER_TYPE; }To copy to clipboard, switch view to plain text mode![]()
Qt 5.3 Opensource & Creator 3.1.2
Either as a member variable or as a superclass. Either way you'll have to reimplement other methods mentioned in the docs if you want to use the structure for anything. But before you do, think if you do need the structure at all. You might use QStandardItem without subclassing - just use custom roles and set your data.
How do I use custom roles? I've been reading docs but I still do not see the way how to do this task.
Qt 5.3 Opensource & Creator 3.1.2
Role is simply a number. Just use setData() and data() with a number of your choice but not less than Qt::UserRole. I think the docs are quite clear about it. You can also take a look at the wiki article about [wiki=QAbstractItemModel]models[/wiki].
Well, I've reimplemented QAbstractTableModel and QTableView, it works ok. The last step is to reimplement QStandardItem for delegate get to work. But right now I am confused regarding layouts. In the attachemnt there is a GUI of my application module. Well, widgets named "QPUSHBUTTON1" and "QTABLEVIEW" are connected via QVBoxLayout. This vertical layout resided with main operation's window (wich is also vertical layouted with 3 pushbuttons placed under it - the 3 pushbuttons are horiz. layouted) vertical layout in horizontal layout. Now, the layout of QPUSHBUTTON1 and QTABLEVIEW is too wide. Now, how can I make main operation window wider and QPUSHBUTTON1 with QTABLEVIEW narrower. Do I have to begin experiment with layouts or the widgets inside "actor" layouts?
Qt 5.3 Opensource & Creator 3.1.2
You can adjust horizontal stretches and/or size policies of widgets.
Well, I used resize function, but there are no results ...![]()
Qt 5.3 Opensource & Creator 3.1.2
Resize won't work as layouts override it. Use what I suggested.
well, if I knew what you thought I would not be asking now ...Will go now read docs, thanks for hints and tips, wysota...
Qt 5.3 Opensource & Creator 3.1.2
I told you the names of fields in Designer. I think I can expect someone with at least two years of experience to locate them there.
Bookmarks