QTableWidget in a QTreeWidget



  • Hi everybody,
    I have a basic QTreeWidget with two columns and i try to add a QTableWidget in the second one using a QTreeWidgetItem and the setItemWidget function.
    If i display anything but a QTableWidget i have no issue but with a table i have a weird flickering effect when i move my mouse over the QTreeWidgetItem its background is often paint over the table and i don't know why :(
    Any idea ? Thanks

    !http://img696.imageshack.us/img696/2514/treewidget.jpg(My QTreeWidget containing a QTableWidget)!



  • I'd recommend you check out the offer from "ICS":http://www.ics.com/products/qt/qicstable/ or from "DevMachines":http://www.devmachines.com/qtitandatagrid-overview.html as they already provide such things, if I remember correctly. Doing this yourself based on Qts item views is going to be hard.



  • I am sorry but ... is it a joke ? :p
    It is just a very basic table in a very basic tree, i guess it's a Qt supported feature no ?
    I don't want to do anything complicated with it, just inserting some numbers.
    Thank you for taking the time to answer me





  • [quote author="silver356" date="1343299755"]I am sorry but ... is it a joke ? :p
    It is just a very basic table in a very basic tree, i guess it's a Qt supported feature no ?
    I don't want to do anything complicated with it, just inserting some numbers.
    Thank you for taking the time to answer me[/quote]

    No jokes. Putting widgets inside item vies (and that is what you do, even if the widget is yet another item view), is not trivial. Unless a standard tree is enough for you?



  • Interesting, what do you mean about standard tree ?



  • A tree like [[doc:QTreeView]] provides you.



  • Oh ok i did not know that a QTreeView was more "standard" than a QTreeWidget i though it was the opposite. So you think using this kind of tree will solve my problem ? I just need to put some text and widgets in the tree.
    Thank you !



  • The need to put widgets in the tree is the problem. That is going to be hard to do well and make perform well. Note that QTreeView is the base class of QTreeWidget. QTreeWidget just adds a buid-in model.

    So no, QTreeView will not help you do that, even though there is the setIndexWidget method in [[doc:QAbstractItemView]]. That might work for you, but it is not what I call model-view programming.



  • [quote author="silver356" date="1343293698"]Hi everybody,
    If i display anything but a QTableWidget i have no issue but with a table i have a weird flickering effect when i move my mouse over the QTreeWidgetItem its background is often paint over the table and i don't know why :(
    [/quote]
    Back to the initial problem.
    The flickering might be caused by the standard style settings for the treeview. Try to change the QStyleSheet for your treeview (especially the setting for QTreeView::item:hover).
    Have a look at "this example":http://qt-project.org/doc/qt-4.8/stylesheet-examples.html#customizing-qtreeview. Maybe if you change the setting for QTreeView::item:hover to nothing, or something different then the standard setting, this might solve the flickering problem.



  • Thank you but it does not seem to work :/

    One weird thing is that when i manually change something in my table (add a value for instance), it draws correctly untill the table release !



  • Sorry it didn't help. But as Andre already mentioned doing a Widget in a Table- Tree- or Whatever-View is not as trivial as it might seem at first glance.
    = /



  • Ok thank you both for your very useful help. I think i will try to handle a hierarchy directly through a table i suppose it will avoid those kind of bugs, no ?



  • Do you know how the Property Editor in QtDesigner is done ? What kind of container is it ? Its cell seems to be able to contain QWidget.



  • I'd suggest you get yourself the sources for QtDesigner, and have a look. The widgets it contains are the same widgets any item view can contain: editors for the items you're editing. That's why you first have to start an edit before you can even check or uncheck a checkbox in that editor, or before you can change an integer.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.