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.9k 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 Offline
    V Offline
    vhptt89
    wrote on last edited by
    #5

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

    mrjjM 1 Reply Last reply
    0
    • V vhptt89

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

      mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on 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 last edited by
        #7

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

        mrjjM 1 Reply Last reply
        0
        • V vhptt89

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

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on 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 last edited by
            #9

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

            mrjjM 1 Reply Last reply
            0
            • V vhptt89

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

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on 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 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.

                mrjjM 1 Reply Last reply
                0
                • V vhptt89

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

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on 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 last edited by vhptt89
                    #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?

                    mrjjM 1 Reply Last reply
                    0
                    • V vhptt89

                      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?

                      mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by mrjj
                      #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 last edited by
                        #15

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

                        1 Reply Last reply
                        1

                        • Login

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