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

How to change Qcombobox popup width

Scheduled Pinned Locked Moved General and Desktop
18 Posts 3 Posters 11.9k 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.
  • A Offline
    A Offline
    advseo32
    wrote on 7 Aug 2013, 16:42 last edited by
    #3

    i have implemented this but still not working as i want
    ( Qcombobox editor should not resize , only the view inside it that can be resized )

    her is my code

    @void MyQComboBox::showPopup()
    {
    QWidget *view = this->view() ;
    int width = view->width();
    this->setMinimumWidth(width);
    QComboBox::showPopup();
    }@

    it's like so

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

    1 Reply Last reply
    0
    • R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 7 Aug 2013, 17:00 last edited by
      #4

      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.

      --- 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, 17:06 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 7 Aug 2013, 17:18 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
          • 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