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. QT I want to increase the size of comboBox Down list not the drop- Down icon ?
Forum Updated to NodeBB v4.3 + New Features

QT I want to increase the size of comboBox Down list not the drop- Down icon ?

Scheduled Pinned Locked Moved Solved General and Desktop
19 Posts 4 Posters 8.1k 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 amarism

    @mrjj So i need to create QTableWidget inside the comboBox or any other method to do this

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

    @amarism
    I dont know what u mean.
    Link talks about overriding showPopup to alter size.
    That should do it.

    A 1 Reply Last reply
    0
    • mrjjM mrjj

      @amarism
      I dont know what u mean.
      Link talks about overriding showPopup to alter size.
      That should do it.

      A Offline
      A Offline
      amarism
      wrote on last edited by
      #11

      @mrjj Still i am not getting any proper solution for this question

      jsulmJ 1 Reply Last reply
      0
      • A amarism

        @mrjj Still i am not getting any proper solution for this question

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #12

        @amarism Did you try what @mrjj suggested?

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        A 1 Reply Last reply
        1
        • jsulmJ jsulm

          @amarism Did you try what @mrjj suggested?

          A Offline
          A Offline
          amarism
          wrote on last edited by
          #13

          @jsulm yup but still this one not working

          mrjjM 1 Reply Last reply
          0
          • A amarism

            @jsulm yup but still this one not working

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

            @amarism
            In what way did it not work for you ?
            Seems to work as expected.
            alt text

            class WideComboBox : public QComboBox
            {
                Q_OBJECT
            public:
                explicit WideComboBox(QWidget *parent = nullptr) : QComboBox(parent) {};
                ~WideComboBox() {}
            public:
                void showPopup() {
                    this->view()->setMinimumWidth(this->view()->sizeHintForColumn(0));
                    QComboBox::showPopup();
                }
            };
            
            

            setting it to 400 ;)

            alt text

            A 1 Reply Last reply
            5
            • J.HilkJ Offline
              J.HilkJ Offline
              J.Hilk
              Moderators
              wrote on last edited by
              #15

              Additionally to what @mrjj wrote, you should also be able to set the size of the view via a StyleSheet, a viable option if you don't plan to vary the size all to often

              ui->comboBox->setStyleSheet("QComboBox QAbstractItemView {min-width: 400px;}"),


              Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


              Q: What's that?
              A: It's blue light.
              Q: What does it do?
              A: It turns blue.

              A 2 Replies Last reply
              2
              • mrjjM mrjj

                @amarism
                In what way did it not work for you ?
                Seems to work as expected.
                alt text

                class WideComboBox : public QComboBox
                {
                    Q_OBJECT
                public:
                    explicit WideComboBox(QWidget *parent = nullptr) : QComboBox(parent) {};
                    ~WideComboBox() {}
                public:
                    void showPopup() {
                        this->view()->setMinimumWidth(this->view()->sizeHintForColumn(0));
                        QComboBox::showPopup();
                    }
                };
                
                

                setting it to 400 ;)

                alt text

                A Offline
                A Offline
                amarism
                wrote on last edited by amarism
                #16

                can i add the vertical spacing between the rows

                1 Reply Last reply
                0
                • J.HilkJ J.Hilk

                  Additionally to what @mrjj wrote, you should also be able to set the size of the view via a StyleSheet, a viable option if you don't plan to vary the size all to often

                  ui->comboBox->setStyleSheet("QComboBox QAbstractItemView {min-width: 400px;}"),

                  A Offline
                  A Offline
                  amarism
                  wrote on last edited by
                  #17

                  @J.Hilk Thanku @J-Hilk . Now its working for me

                  1 Reply Last reply
                  0
                  • J.HilkJ J.Hilk

                    Additionally to what @mrjj wrote, you should also be able to set the size of the view via a StyleSheet, a viable option if you don't plan to vary the size all to often

                    ui->comboBox->setStyleSheet("QComboBox QAbstractItemView {min-width: 400px;}"),

                    A Offline
                    A Offline
                    amarism
                    wrote on last edited by
                    #18

                    @J.Hilk One more problem comes here, I am added a icon for combo box . And it will showing inside the dropdown popup. can i hide from icom from dropdown button

                    J.HilkJ 1 Reply Last reply
                    0
                    • A amarism

                      @J.Hilk One more problem comes here, I am added a icon for combo box . And it will showing inside the dropdown popup. can i hide from icom from dropdown button

                      J.HilkJ Offline
                      J.HilkJ Offline
                      J.Hilk
                      Moderators
                      wrote on last edited by
                      #19

                      @amarism I don't think you can do that via the StyleSheet. My guess would be to subclass QComboBox and override the paintEvent and ignore the Qt::DecorationRole !?


                      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                      Q: What's that?
                      A: It's blue light.
                      Q: What does it do?
                      A: It turns blue.

                      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