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. QDateTimeEdit and QComboBox height in QToolBar

QDateTimeEdit and QComboBox height in QToolBar

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 515 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.
  • J Offline
    J Offline
    JohnGa
    wrote on last edited by
    #1

    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.

    ToolBarIssue.png

    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

    eyllanescE 1 Reply Last reply
    0
    • J JohnGa

      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.

      ToolBarIssue.png

      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

      eyllanescE Offline
      eyllanescE Offline
      eyllanesc
      wrote on last edited by
      #2

      @JohnGa use sizePolicy: combobox->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);

      If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

      1 Reply Last reply
      0
      • J Offline
        J Offline
        JohnGa
        wrote on last edited by JohnGa
        #3

        @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.

        eyllanescE 1 Reply Last reply
        0
        • J JohnGa

          @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.

          eyllanescE Offline
          eyllanescE Offline
          eyllanesc
          wrote on last edited by
          #4

          @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();
          }
          

          Screenshot_20210923_203912.png

          And as you can see, the first QComboBox occupies the same height as the QToolButton as opposed to the second QComboBox.

          If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

          1 Reply Last reply
          2
          • J Offline
            J Offline
            JohnGa
            wrote on last edited by
            #5

            @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.

            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