[Interest] QTreeWidget displays blank widget

Nicolas Krieger nicolas.krieger at medecom.fr
Fri Aug 10 12:26:53 CEST 2018


I have finally managed to do what I wanted in using styleSheets. Not 
really beautiful.



If a have a widget containing all other widgets, for which I defined a 
styleSheet, the color will be displayed only for the children (see last 
example).
The "solution" is to have a child widget that contains all other widgets.
In this example, a stylesheet is define for "widget_2". It is correctly 
displayed in the tree.





In this example, no stylesheet for "widget_2" and the palette's 
background color of "SimpleWidget" is blue.




In this example, there is no "widget_2" and a stylesheet is defined for 
"SimpleWidget".
Using the first example can be a solution.


Le 09/08/2018 à 18:13, Murphy, Sean a écrit :
>> Yes, I used QTreeWidget ::setCellWidget(int row, int column, QWidget *widget).
>> I have already used QStyledItemDelegate, but setCellWidget is far easiest for what I want to do.
>> I don't really understand why QPushbutton are correctly displayed and not other widgets.
>> But if only delegate is the solution, I will use it.
>  From the discussion I had with support, it appears that QTableWidget is expecting a
> QTableWidgetItem to define the colors for QPalette::ForegroundRole and QPalette::BackgroundRole,
> but since you're using setCellWidget() you're most likely not adding a QTableWidgetItem to the
> cell. Which even if you were, I don't think would get what you want since you have two different
> background colors (the orange and the blue) as the background of the two labels. I don't know
> if using QStyledItemDelegate gets you over that hurdle either, since I don't see how it allows you
> to set different BackgroundRole values for the QLabel child widgets?
>
> If you come up with a good solution, please respond to the list (or at least respond to me personally!)
> as I'm interested in the correct solution to this as well just in case we decide to come back around to
> this idea for our project.
>
> Sean
>
>
> This message has been scanned for malware by Forcepoint. www.forcepoint.com
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest

-- 
*Nicolas Krieger*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20180810/d06df9ec/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ddnippkmjbkcbjhe.png
Type: image/png
Size: 12437 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20180810/d06df9ec/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cljfdogopcobhffe.png
Type: image/png
Size: 11046 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20180810/d06df9ec/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pelgjlnokbcghoap.png
Type: image/png
Size: 10919 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20180810/d06df9ec/attachment-0002.png>


More information about the Interest mailing list