Solved QT I want to increase the size of comboBox Down list not the drop- Down icon ?
-
@amarism
Just adjust to what u want
QSize(100, 100) is the size. 100 width, 100 heightBut the width of the drop-down is the width of the combo itself
-
@mrjj I don't want to increase the size of header combo box . Becaue i am using combobox as a button in my ui viewer. So, I can't set button size this much. I want the combo Box like this
-
@amarism
ok.
you need to subclass for that i think.
https://forum.qt.io/topic/30405/how-to-change-qcombobox-popup-widthAlternatively, you canuse toolbutton and QMenu.
-
@mrjj So i need to create QTableWidget inside the comboBox or any other method to do this
-
@amarism
I dont know what u mean.
Link talks about overriding showPopup to alter size.
That should do it. -
@mrjj Still i am not getting any proper solution for this question
-
-
@jsulm yup but still this one not working
-
@amarism
In what way did it not work for you ?
Seems to work as expected.
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 ;)
-
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;}"),
-
can i add the vertical spacing between the rows
-
-
@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
-
@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 theQt::DecorationRole
!?