Stylesheet for promoted frame
-
<widget class="QWidget" name="centralWidget"> <widget class="FrameTest" name="frame"> <property name="geometry"> <rect> <x>30</x> <y>30</y> <width>501</width> <height>401</height> </rect> </property>
Plz check this part on MainWindow.ui.
In the ui_mainwindow.h, the FrameTest actually constructed. -
@vhptt89
Maybe I dont understand you.If you set the stylesheet inside your own class. Then its first seen when your code runs.
If you set the stylesheet on the mainwinow, then it will also affect the promote
qframe and the FrameTest.Since the QFrame is NOT really a FrameTest before its run, it will not show as red in the Designer.
-
As i said above, I set it by using QtDesigner in FrameTest.ui:
<property name="styleSheet">
<string notr="true">QFrame {background: red;}</string>
</property>I know I can use another way to do it ( @mrjj suggestion is a good one ). But I needs an explain about why did the stylesheet not affect to my promoted frame?
-
Ahh, sorry. @Ratzz told me what you ment.
Yes, that is a bit odd. since its sets the stylesheet in ctor so it should also be
red when running.If you look in ui_mainwindow.hfile it has generated the code
frame = new FrameTest(centralWidget); <<<<<<<<<<<<<<<<<< red style is set in here
frame->setObjectName(QStringLiteral("frame"));
frame->setGeometry(QRect(10, 10, 621, 471));
frame->setStyleSheet(QStringLiteral("")); <<<<<<<<<<<<<<<<<<<<<<<< BUT it clear the red one here.So i think you at some point had style sheet on the promote qframe?
If you place a new QFrame and promote it, it works :)The reason it dont work here is that style is set in FrameTest ctor and then set
to blank in mainwin setupUI.To make it work for the existing, find stylesheet to the right in prop list and click the reset button. then it stops insert this blank stylesheet in main ui.
Just deleting the stylesheet (inside editor) wont work.
You must use the clear button.