PDA

View Full Version : The Widget in qt´s Designer



LordQt
28th August 2007, 07:13
HEllo friends,

I have a question early in the morning ;o). What widget tyle is in use in the left side of the designer (qt) . I would like to program the same widget. How can i do that, it seems it is no standard widget? Isn´t it?

jpn
28th August 2007, 08:25
If you mean the Widget Box (http://doc.trolltech.com/4.3/designer-getting-started.html#widgetbox), it's a QTreeWidget with a custom delegate (http://doc.trolltech.com/4.3/model-view-delegate.html) which renders top level items as buttons. See Designer's sources for more details:

$QTDIR/tools/designer/src/components/widgetbox.*
$QTDIR/tools/designer/src/lib/shared/sheet_delegate.*

jpn
9th September 2007, 07:21
I think the philosophie of a forum is another i am not a trolltech men to read the code from the designer
Hey, me neither! However, they use a custom technique for painting top level items. It's not a built-in feature one can just turn on nor it's documented anywhere. That's why I pointed out where it's implemented so you could have taken look how they do it.

I don't have Qt sources on this computer so right now I'm unable to give you more detailed instructions than looking for SheetDelegate::paint() in the source files that were already mentioned. As far as I remember, it checks whether an item being painted is a top level item and if so, paints it as a button with the help of styles. Implement a similar item delegate, and use QAbstractItemView::setItemDelegate() to take it into use.

LordQt
9th September 2007, 14:30
Thanks for your explanations, but I don´t say that you are a Troll. I have just pointest out my opinion thats the reason I asked twice the same think because the answet that you gave me don´t satisfied me.
Whatever I thank you that you show me the that i must go. It seems to be a hard way ;o))

LordQt
11th November 2007, 20:02
Hello friends,

I´am always coding my treeview like the designer one.


QDockWidget *docktree = new QDockWidget(tr("MyTestTree"), this);
docktree->minimumHeight();
docktree->setAutoFillBackground(true);
docktree->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
ControlView= new QTreeView();
ControlView->setItemsExpandable(true);

QStandardItemModel *itemmodel = new QStandardItemModel();

for (int i = 0; i < 5; ++i)
itemmodel->setItem(i, new QStandardItem(QString("Row: ") + QString::number(i)));


ControlView->setModel(itemmodel);
SheetDelegate *myDelegate = new SheetDelegate(ControlView,docktree);
ControlView->setItemDelegate(myDelegate);


;o) See the attachment how it looks ;o))

but i have some question.
How can I add some children´s to my items?
And how can I hide the root above my first item in my view?

wysota
11th November 2007, 20:40
As far as I remember, to hide the root, you need to set the "rootIsDecorated" property of the tree to false. As for adding items, you need to create a model that will contain a hierarchy of items. If you don't want to create your own model, you can use QStandardItemModel, it's capable of creating hierarchies.

LordQt
11th November 2007, 21:08
Hello thanx for reply,

when I set rootIsDecorated to false my View changes in see attachment. But the Label with the string "1" also exists.

hm and now ??

wysota
11th November 2007, 21:20
Oh come on... why don't you try something yourself before asking here for each and every problem you are facing? You won't learn much this way... The "1" is the default name of the header of the tree. If you hide the header, the problem will go away. You can access the header through one of the members of QTreeView class.

LordQt
11th November 2007, 21:33
So thats enough,

I think about never write here again.
What do you talkin about. I am searching now 1 hour for this fuckin member. As far as I remember this is a forum about those "silly" question ( sorry for my badness).



P.S.: Pride goes before a fall.


Thanks for your professional help.

wysota
11th November 2007, 22:49
What do you talkin about. I am searching now 1 hour for this fuckin member.

Try the one that is called "header". And watch your language, please - no need to be upset. Our policy is to give fishing rods and not fish. If you refuse a rod, you'll get your fish, but you'll be unable to catch one by yourself next time.