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.
-
-
check "this":http://qt-project.org/forums/viewthread/16673/ and "this":http://qt-project.org/forums/viewthread/16837/
-
[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?
-
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. -
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.