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 change Qcombobox popup width
QtWS25 Last Chance

How to change Qcombobox popup width

Scheduled Pinned Locked Moved General and Desktop
18 Posts 3 Posters 11.8k Views
  • 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
    raven-worx
    Moderators
    wrote on 7 Aug 2013, 18:26 last edited by
    #7

    this->view() returns an QAbstractItemView which is derived from QWidget. QWidget has a method named setMinimumWidth() ....
    what Qt version do you use?!

    --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
    If you have a question please use the forum so others can benefit from the solution in the future

    1 Reply Last reply
    0
    • A Offline
      A Offline
      advseo32
      wrote on 7 Aug 2013, 19:53 last edited by
      #8

      [quote author="raven-worx" date="1375899990"]this->view() returns an QAbstractItemView which is derived from QWidget. QWidget has a method named setMinimumWidth() ....
      what Qt version do you use?![/quote]

      Sure, QWidget has a member function setMinimumWidth(),

      my problem is inside setMinimumWidth(),

      this->view()->sizeHintForColumn(0) ( QWidget hasn't a methode sizeHintForColumn(0)

      1 Reply Last reply
      0
      • R Offline
        R Offline
        raven-worx
        Moderators
        wrote on 7 Aug 2013, 19:58 last edited by
        #9

        no...but QAbstractItemView does!
        Since you implicitly cast the view instance to a QWidget it's clear that the compiler complains about it!

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        0
        • A Offline
          A Offline
          advseo32
          wrote on 7 Aug 2013, 23:04 last edited by
          #10

          [quote author="raven-worx" date="1375905485"]no...but QAbstractItemView does!
          Since you implicitly cast the view instance to a QWidget it's clear that the compiler complains about it![/quote]

          I have no idea how i can do this

          1 Reply Last reply
          0
          • R Offline
            R Offline
            raven-worx
            Moderators
            wrote on 8 Aug 2013, 07:16 last edited by
            #11

            change the line
            @
            QWidget *view = this->view() ;
            @
            to
            @
            QAbstractItemView *view = this->view() ;
            @

            or just use the code i've posted in first place!

            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
            If you have a question please use the forum so others can benefit from the solution in the future

            1 Reply Last reply
            0
            • A Offline
              A Offline
              advseo32
              wrote on 9 Aug 2013, 19:09 last edited by
              #12

              [quote author="raven-worx" date="1375946208"]change the line
              @
              QWidget *view = this->view() ;
              @
              to
              @
              QAbstractItemView *view = this->view() ;
              @

              or just use the code i've posted in first place![/quote]

              also not working for me , always the width of Qtableview don't increased

              1 Reply Last reply
              0
              • A Offline
                A Offline
                advseo32
                wrote on 10 Aug 2013, 07:34 last edited by
                #13

                how i can increase only the width of popup (Qtableview) ???

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  advseo32
                  wrote on 10 Aug 2013, 11:50 last edited by
                  #14

                  like so,
                  ////////////////////////////////
                  // combobox //
                  //////////////////////////////////////////////////////////////////////////////////
                  // Qtableview her with all cells inside it ** Horizontal Header //
                  /////////////////////////////////////////////////////////////////////////////////
                  /// row 0 //
                  /////////////////////////////////////////////////////////////////////////////////
                  /// row 1 //
                  /////////////////////////////////////////////////////////////////////////////////
                  /// row 2 //
                  /////////////////////////////////////////////////////////////////////////////////

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    advseo32
                    wrote on 11 Aug 2013, 06:57 last edited by
                    #15

                    no body know about this ?

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      advseo32
                      wrote on 12 Aug 2013, 17:36 last edited by
                      #16

                      plz inform me if my question is clear or no ?

                      1 Reply Last reply
                      0
                      • A Offline
                        A Offline
                        advseo32
                        wrote on 13 Aug 2013, 16:38 last edited by
                        #17

                        i have used this but not working

                        1 Reply Last reply
                        0
                        • B Offline
                          B Offline
                          Bowdzone
                          wrote on 7 Oct 2013, 09:33 last edited by
                          #18

                          This works perfect, Thank you very much.

                          [quote author="raven-worx" date="1375879559"]you can subclass QComboBox and reimplement showPopup() method if you need the size content dependent. Something like this:
                          @
                          void MyComboBox::showPopup()
                          {
                          this->view()->setMinimumWidth(this->view()->sizeHintForColumn(0));
                          QComboBox::showPopup();
                          }
                          @[/quote]

                          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