Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Stylesheet for promoted frame
Forum Updated to NodeBB v4.3 + New Features

Stylesheet for promoted frame

Scheduled Pinned Locked Moved Solved General and Desktop
qssstylesheetpromote
15 Posts 2 Posters 5.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V vhptt89
    7 Jul 2016, 07:53

    @mrjj

    <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.

    M Offline
    M Offline
    mrjj
    Lifetime Qt Champion
    wrote on 7 Jul 2016, 07:58 last edited by
    #6

    @vhptt89

    where is the style sheet applied?

    If its NOT applied to mainwinow, then
    its first in effect after the
    setupUI has been run.

    1 Reply Last reply
    1
    • V Offline
      V Offline
      vhptt89
      wrote on 7 Jul 2016, 08:01 last edited by
      #7

      @mrjj
      It applied in FrameTest.ui.
      It quite simple: QFrame{background: red;}

      M 1 Reply Last reply 7 Jul 2016, 08:03
      0
      • V vhptt89
        7 Jul 2016, 08:01

        @mrjj
        It applied in FrameTest.ui.
        It quite simple: QFrame{background: red;}

        M Offline
        M Offline
        mrjj
        Lifetime Qt Champion
        wrote on 7 Jul 2016, 08:03 last edited by
        #8

        @vhptt89

        Ok,
        it wont affect the promoted before app is run.

        1 Reply Last reply
        0
        • V Offline
          V Offline
          vhptt89
          wrote on 7 Jul 2016, 08:08 last edited by
          #9

          @mrjj Is that the conclusion? So I cant do it that way?

          M 1 Reply Last reply 7 Jul 2016, 08:16
          0
          • V vhptt89
            7 Jul 2016, 08:08

            @mrjj Is that the conclusion? So I cant do it that way?

            M Offline
            M Offline
            mrjj
            Lifetime Qt Champion
            wrote on 7 Jul 2016, 08:16 last edited by
            #10

            @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.

            1 Reply Last reply
            1
            • V Offline
              V Offline
              vhptt89
              wrote on 7 Jul 2016, 08:51 last edited by
              #11

              @mrjj
              I set the stylesheet inside my own class, But it didnt display correctly in runtime.
              And I dont care about how it show in the Designer.

              M 1 Reply Last reply 7 Jul 2016, 08:54
              0
              • V vhptt89
                7 Jul 2016, 08:51

                @mrjj
                I set the stylesheet inside my own class, But it didnt display correctly in runtime.
                And I dont care about how it show in the Designer.

                M Offline
                M Offline
                mrjj
                Lifetime Qt Champion
                wrote on 7 Jul 2016, 08:54 last edited by
                #12

                @vhptt89
                Ok, can you show the code where you set it?

                Also try with no name
                setStyleSheet("{background: red;}");

                1 Reply Last reply
                0
                • V Offline
                  V Offline
                  vhptt89
                  wrote on 7 Jul 2016, 08:56 last edited by vhptt89 7 Jul 2016, 09:05
                  #13

                  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?

                  M 1 Reply Last reply 7 Jul 2016, 10:04
                  0
                  • V vhptt89
                    7 Jul 2016, 08:56

                    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?

                    M Offline
                    M Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on 7 Jul 2016, 10:04 last edited by mrjj 7 Jul 2016, 10:40
                    #14

                    @vhptt89

                    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.

                    1 Reply Last reply
                    1
                    • V Offline
                      V Offline
                      vhptt89
                      wrote on 7 Jul 2016, 10:39 last edited by
                      #15

                      @mrjj @Ratzz Thank u guys alot for helping me fix this prob.

                      1 Reply Last reply
                      1

                      15/15

                      7 Jul 2016, 10:39

                      • Login

                      • Login or register to search.
                      15 out of 15
                      • First post
                        15/15
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved