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.
  • A Offline
    A Offline
    advseo32
    wrote on last edited by
    #5

    i can't use this code @this->view()->setMinimumWidth(this->view()->sizeHintForColumn(0));@

    the compiler show me an error !!!

    this->view() it's ok but this->view()->setMinimumWidth() it's not possible
    (because there is no member setMinimumWidth of this->view())

    1 Reply Last reply
    0
    • A Offline
      A Offline
      advseo32
      wrote on last edited by
      #6

      [quote author="raven-worx" date="1375894826"]and you can't see a difference between my and your code?!
      You set the minimum width to width... you wont notice anything with that code.[/quote]

      Ok, i have figured out what you mean

      @void MyQComboBox::showPopup()
      {
      QWidget *view = this->view() ;
      // i can't use this because
      // QWidget hasn't a method (sizeHintForColumn())
      // so i have used this
      this->setMinimumSize(view->sizeHint());
      // but still i have a problem
      QComboBox::showPopup();
      }
      @

      like so,

      ////////////////////////////////////
      // combobox //
      // //
      // I don't need this Height //
      // //
      // //
      ////////////////////////////////////
      // Qtableview her with all //
      //cells inside it ** Horizon //
      // Header // //
      ///////////////////////////////////
      /// row 0 // //
      //////////////////////////////////
      /// row 1 //
      /////////////////////////////////

      1 Reply Last reply
      0
      • raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on 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 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
          • raven-worxR Offline
            raven-worxR Offline
            raven-worx
            Moderators
            wrote on 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 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
              • raven-worxR Offline
                raven-worxR Offline
                raven-worx
                Moderators
                wrote on 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 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 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 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 last edited by
                        #15

                        no body know about this ?

                        1 Reply Last reply
                        0
                        • A Offline
                          A Offline
                          advseo32
                          wrote on 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 last edited by
                            #17

                            i have used this but not working

                            1 Reply Last reply
                            0
                            • B Offline
                              B Offline
                              Bowdzone
                              wrote on 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