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.
  • ivanicyI Offline
    ivanicyI Offline
    ivanicy
    wrote on 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!!

    Venkatesh VV 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on 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
      • ivanicyI Offline
        ivanicyI Offline
        ivanicy
        wrote on 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
        0
        • ivanicyI ivanicy

          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 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
          • ivanicyI ivanicy

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

            Venkatesh VV Offline
            Venkatesh VV Offline
            Venkatesh V
            wrote on 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;
            

            }

            mrjjM 1 Reply Last reply
            1
            • Venkatesh VV Venkatesh V

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

              }

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

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

              Venkatesh VV 1 Reply Last reply
              1
              • mrjjM mrjj

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

                Venkatesh VV Offline
                Venkatesh VV Offline
                Venkatesh V
                wrote on last edited by
                #7

                @mrjj
                Hi,

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

                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