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. [SOLVED] How to get QComboBox arrow width?
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] How to get QComboBox arrow width?

Scheduled Pinned Locked Moved General and Desktop
7 Posts 3 Posters 5.2k 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.
  • R Offline
    R Offline
    RazrFalcon
    wrote on last edited by
    #1

    I mean this:
    !http://storage6.static.itmages.ru/i/11/1029/h_1319889058_5951390_a1f85da7d3.png!

    Is it possible?
    I want to add QToolButton just before this arrow.

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on last edited by
      #2

      getting this size can be achieved by the style, where also QComboBox itself reads it from.

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      1 Reply Last reply
      0
      • R Offline
        R Offline
        RazrFalcon
        wrote on last edited by
        #3

        I'm misunderstood. Can you give a code example?
        Thanks.

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dangelog
          wrote on last edited by
          #4

          See http://doc.qt.nokia.com/4.7/style-reference.html#combo-box

          Software Engineer
          KDAB (UK) Ltd., a KDAB Group company

          1 Reply Last reply
          0
          • R Offline
            R Offline
            RazrFalcon
            wrote on last edited by
            #5

            Still can't understand :(

            1 Reply Last reply
            0
            • G Offline
              G Offline
              giesbert
              wrote on last edited by
              #6

              You need something like:

              subclass QCombobox, use "QStyle::subControlRect":http://doc.qt.nokia.com/4.7/qstyle.html#subControlRect

              @
              MyCombo::foo()
              {
              QStylre* pStyle = style();
              QComboBoxStyleOption opt;
              opt.initFrom(this);
              QRect rc = pStyle->subControlRect(QStyle::CC_ComboBox, opt, QStyle::SC_ComboBoxArrow, this);
              }
              @

              Code just written in the forum, not tested

              But take, care, then you overlay the text field.

              Nokia Certified Qt Specialist.
              Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

              1 Reply Last reply
              0
              • R Offline
                R Offline
                RazrFalcon
                wrote on last edited by
                #7

                Thanks a lot!

                This works for me:
                @QStyle *pStyle = style();
                QStyleOptionComboBox opt;
                opt.initFrom(this);
                QRect rc = pStyle->subControlRect(QStyle::CC_ComboBox, &opt, QStyle::SC_ComboBoxArrow, this);
                qDebug()<<rc.width();@

                1 Reply Last reply
                0

                • Login

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