This is the base class implementation provided that MyClass inherits BaseClass.Qt Code:
void MyClass::method(int x, int y){ BaseClass::method(x,y); // <-- }To copy to clipboard, switch view to plain text mode
This is the base class implementation provided that MyClass inherits BaseClass.Qt Code:
void MyClass::method(int x, int y){ BaseClass::method(x,y); // <-- }To copy to clipboard, switch view to plain text mode
Maybe you understand me wrong or I unserstand you wrong. :P I need to draw a totaly other qwidget than the QTreeView base class rows in my case. I want to draw some widget that I had created already from a QFrame with some some buttons on it, I want to draw it on the place where the row must be drawed instead of the real QTreeView rows, so calling BaseClass::method will not do the thing that I want to do.So that was my previous question, can I draw my own widget with other widgets placed on it instead of the rows using directly the painter. I hope you understand me right this time.
![]()
Items are drawn using drawRow(), which will in turn call the delegate to draw each item. Now you have two possible solutions. Either fake a widget drawing all the contents yourself or use index widgets (these are real widgets) and then widgets will draw themselves. The latter will slow your application down significantly if you have more than a few of them, so the first solution is advised. If you want a list of contacts, I doubt you have to use real widgets, so painting in the delegate's paint method is the way to go. Search the forum for more details on this.
Hi again
I have been busy with other things but now I'm back to coding my messenger, after all readed again and again I do understand that I need to use a real widgets in to the TreeView, because of the functionality of each user in the list with only clicking on the widget. As you told me this will slow down the application but from what I see in other messengers they do have widgets in the contact list but only one in a time. I meant that general the list of users in the list looks like a totaly normal items for treeview with some icon for status, but when you select someone he become a widget with some or other options on it like in Skype for example, when you select other user the previous selected become a normal item again and the other user become in widget and etc... So I do know how to instert widgets in TreeView (I think, there is some from the examples doing it) and I do know how to instert normal items, but I really don't know how to do the change like the messengers like Skype do - only the selected user become a widget and in this way the program is not slowing down. Do you have any idea for some kind of way that I can do this too ?
Thanks a lot for your help but new people in Qt like me needs more and more... Sorry if you are bored of my questions.![]()
They have a tree and the "expanded" view is simply a child item of the "base" view item.
My english is not very good so maybe I can't fully understand you, can you show me little example pleace.![]()
Skype is your example
A single "contact" consists of two items where one is a child of the other. When the contact is "active" you see both items and when it is "collapsed" you only see the parent item. At this moment the child is hidden.
Ok but QTreeView doesn't accept my QItemDelegate modification that I copied one to one from the examples(SpinBoxDelegate). The example use QTableView... Am I forced to use QTableView too and is QTableView able to hold a normal items like QTreeView? Or is there a better easy way to do the stuff like inserting a widget in to the view without QItemDelegate ?
Last edited by The Storm; 12th January 2008 at 21:19.
What does "doesn't accept" mean?
It meant that nothing is showed but the mistake was mine.The bad thing here is that the item size is very small in to the treeview, is there a way I can resize it and is there other way to show a widget without an ItemDelegate and if not how the parent item can be normal and the child to be widget?
![]()
Set a SizeHintRole for your item.
The Storm (13th January 2008)
Thanks you, this done the job.But now other problem exist - why the widget is showing only when I doble click on the item, I want to be showed always and on one click to expand his child, is there any flags or something to do this ?
Bookmarks