Stylesheet for promoted frame
-
@vhptt89
hi
The promoted qframe is not a FrameTest before
app is run. -
<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. -
where is the style sheet applied?
If its NOT applied to mainwinow, then
its first in effect after the
setupUI has been run. -
Ok,
it wont affect the promoted before app is run. -
@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.
-
@vhptt89
Ok, can you show the code where you set it?Also try with no name
setStyleSheet("{background: red;}"); -
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?
-
mrjj Lifetime Qt Championreplied to vhptt89 on 7 Jul 2016, 10:04 last edited by mrjj 7 Jul 2016, 10:40
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.
12/15