QDateTimeEdit and QComboBox height in QToolBar
-
Hello,
I have QComboBox's and a QDateTimeEdit in a QToolBar. There are other buttons in the toolbar. The buttons occupy the height of the toolbar nicely. However, the QComboBox's and the QDateTimeEdit's don't fully occupy the height of the QToolBar. As can be seen in the image below, there is the empty space above and below. I can't seem to increase the height of the QComboBox or the QDateTimeEdit to fill the height of the toolbar.Pretty sure this must be a common problem. Any ideas on how I can make these widgets more attractive? Are there any other alternative widgets I should use?
Thanks,
JG -
Hello,
I have QComboBox's and a QDateTimeEdit in a QToolBar. There are other buttons in the toolbar. The buttons occupy the height of the toolbar nicely. However, the QComboBox's and the QDateTimeEdit's don't fully occupy the height of the QToolBar. As can be seen in the image below, there is the empty space above and below. I can't seem to increase the height of the QComboBox or the QDateTimeEdit to fill the height of the toolbar.Pretty sure this must be a common problem. Any ideas on how I can make these widgets more attractive? Are there any other alternative widgets I should use?
Thanks,
JG -
@eyllanesc Thanks for taking the time to respond.
I tried various settings via setSizePolicy, but unfortunately the height of the QComboBox remains exactly the same.
-
@eyllanesc Thanks for taking the time to respond.
I tried various settings via setSizePolicy, but unfortunately the height of the QComboBox remains exactly the same.
@JohnGa Are you sure? I just tested using the MRE:
#include <QApplication> #include <QComboBox> #include <QMainWindow> #include <QToolBar> #include <QToolButton> int main(int argc, char *argv[]) { QApplication a(argc, argv); a.setStyle("fusion"); QToolBar *toolBar = new QToolBar; QComboBox *combobox = new QComboBox; combobox->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); QToolButton *button = new QToolButton(); button->setIcon(a.style()->standardIcon(QStyle::SP_TitleBarMinButton)); button->setCheckable(true); button->setChecked(true); toolBar->addWidget(combobox); toolBar->addWidget(button); toolBar->addWidget(new QComboBox); QMainWindow w; w.resize(640, 480); w.show(); w.addToolBar(toolBar); return a.exec(); }
And as you can see, the first QComboBox occupies the same height as the QToolButton as opposed to the second QComboBox.
-
@eyllanesc Thank you so much for the example. Looked at your code closely. When I apply the "fusion" style, yes the comboboxes do size like your example showed. I am on a Mac. That is probably why the comboboxes are not resizing (this must be similar to how some of the other widgets behave on Mac vs other platforms).
Thanks again for your help. I am marking this as resolved.