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. How to custom QComboBox
Forum Updated to NodeBB v4.3 + New Features

How to custom QComboBox

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 5 Posters 4.5k Views 3 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.
  • I Offline
    I Offline
    ivanicy
    wrote on 18 Sept 2017, 10:15 last edited by
    #1

    Hello!!

    Anybody knows where can I consult how can I custom a QComboBox setting the stylesheet?
    I want, for example, change the font size displayed. I want to know the different parts of the QComboBox, etc.

    Thank you very much!!

    V 1 Reply Last reply 18 Sept 2017, 12:23
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 18 Sept 2017, 10:22 last edited by
      #2

      Hi,

      The Qt Style Sheets Reference and the Qt Style Sheets Examples chapter of Qt's documentation.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • I Offline
        I Offline
        ivanicy
        wrote on 18 Sept 2017, 10:28 last edited by
        #3

        Thank you very much but, for example, I have created a QComboBox with a 12pt font size. When I push the QComboBox, the different entries have 8pt font sizes. How can I change it?

        A 1 Reply Last reply 18 Sept 2017, 11:16
        0
        • I ivanicy
          18 Sept 2017, 10:28

          Thank you very much but, for example, I have created a QComboBox with a 12pt font size. When I push the QComboBox, the different entries have 8pt font sizes. How can I change it?

          A Offline
          A Offline
          Alain38
          wrote on 18 Sept 2017, 11:16 last edited by
          #4

          Hi,
          The customization of the llist is the second part of the example (even if it is really short). In fact you have to customize QComboBox QAbstractItemView that corresponds to the list. You might have to add the ::item to customize the items of the list.

          1 Reply Last reply
          2
          • I ivanicy
            18 Sept 2017, 10:15

            Hello!!

            Anybody knows where can I consult how can I custom a QComboBox setting the stylesheet?
            I want, for example, change the font size displayed. I want to know the different parts of the QComboBox, etc.

            Thank you very much!!

            V Offline
            V Offline
            Venkatesh V
            wrote on 18 Sept 2017, 12:23 last edited by
            #5

            @ivanicy
            Hi,

            try by following code and change the properties with your appropriate inputs.

            QComboBox {
            border: 1px solid #333333;
            border-radius: 3px;
            background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #797979, stop:0.48 #696969, stop:0.52 #5e5e5e, stop:1 #4f4f4f);
            padding: 1px 23px 1px 3px;
            min-width: 6em;
            color: #ffffff;
            }
            QComboBox::drop-down {
            subcontrol-origin: padding;
            subcontrol-position: top right;
            width: 20px;

            border-top-right-radius: 3px;
            border-bottom-right-radius: 3px;
            

            }
            QComboBox::down-arrow {
            image: url(:/images/combobox-arrow.png);
            }

            QComboBox QAbstractView{
            background-color: #4f4f4f;
            color: #999999;

            selection-background-color: #999999;
            selection-color: #4f4f4f;
            

            }

            M 1 Reply Last reply 18 Sept 2017, 15:38
            1
            • V Venkatesh V
              18 Sept 2017, 12:23

              @ivanicy
              Hi,

              try by following code and change the properties with your appropriate inputs.

              QComboBox {
              border: 1px solid #333333;
              border-radius: 3px;
              background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #797979, stop:0.48 #696969, stop:0.52 #5e5e5e, stop:1 #4f4f4f);
              padding: 1px 23px 1px 3px;
              min-width: 6em;
              color: #ffffff;
              }
              QComboBox::drop-down {
              subcontrol-origin: padding;
              subcontrol-position: top right;
              width: 20px;

              border-top-right-radius: 3px;
              border-bottom-right-radius: 3px;
              

              }
              QComboBox::down-arrow {
              image: url(:/images/combobox-arrow.png);
              }

              QComboBox QAbstractView{
              background-color: #4f4f4f;
              color: #999999;

              selection-background-color: #999999;
              selection-color: #4f4f4f;
              

              }

              M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 18 Sept 2017, 15:38 last edited by
              #6

              @Venkatesh-V
              Hi
              Its not really changing the items fonts but good start
              alt text

              V 1 Reply Last reply 19 Sept 2017, 04:48
              1
              • M mrjj
                18 Sept 2017, 15:38

                @Venkatesh-V
                Hi
                Its not really changing the items fonts but good start
                alt text

                V Offline
                V Offline
                Venkatesh V
                wrote on 19 Sept 2017, 04:48 last edited by
                #7

                @mrjj
                Hi,

                there i have not assign any value to font item so...

                1 Reply Last reply
                1

                1/7

                18 Sept 2017, 10:15

                • Login

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