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. Controls with listboxes differ between "vista" and "fusion" style?

Controls with listboxes differ between "vista" and "fusion" style?

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 2 Posters 1.1k 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.
  • M Offline
    M Offline
    mireiner
    wrote on last edited by mireiner
    #1

    Hello,

    I like to port my Qt 5.15/16.0 Windows application to Linux. On Windows 10 Qt defaults to "windowsvista" application style - alternative there's "fusion" style available. On Linux Qt defaults to the "fusion" style - there's no other application style available.

    Since the first time I saw my application on Linux I'm confused. Because QComboxBox in comparison with other control-widgets that have listboxes like QListWidget doesn't have equally sized item/menu heights anymore. Scaling doesn't affect this situation:

    alt text

    As you can see in Windows "vista" style both controls have exact the same item/menu height. But in "fusion" style the item/menu height of QComboBox gets much larger and at the same time the item/menu height of QListWidget smaller. That even gets worse using the "fusion" style on Linux.

    Here's my code. Because Linux and Windows use different default fonts the Roboto font is used for better comparison:

    #include <QApplication>
    #include <QWidget>
    #include <QStringList>
    #include <QLabel>
    #include <QComboBox>
    #include <QListWidget>
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        QWidget w;
    
        QLabel labelCombo(&w);
        labelCombo.setFont(QFont("Roboto", 9));
        labelCombo.setText("QComboBox");
        labelCombo.setGeometry(24, 10, 90, 20);
    
        QLabel labelList(&w);
        labelList.setFont(QFont("Roboto", 9));
        labelList.setText("QListWidget");
        labelList.setGeometry(164, 10, 90, 20);
    
        QStringList stringList;
        for (int i=1; i<=20; i++) {
            QString string = QString("Item%1").arg(i);
            stringList.append(string);
        }
    
        QComboBox combo(&w);
        combo.setFont(QFont("Roboto", 9));
        combo.setGeometry(20, 30, 120, 25);
        combo.addItems(stringList);
        combo.setMaxVisibleItems(22);
    
        QListWidget list(&w);
        list.setFont(QFont("Roboto", 9));
        list.setGeometry(160, 30, 120, 344);
        list.addItems(stringList);
    
        w.resize(300,480);
        w.show();
        return a.exec();
    }
    

    Because I couldn't find any complains about this issue in the internet I wonder if there might be something wrong with my code?

    How to make all control-widgets that got listboxes look more uniform on Linux? Like it's on Windows 10 with it's default "vista" style?

    Best regards,
    mireiner

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      It's all fine. The style is responsible on how to draw the widgets and the fusion style uses some larger elements.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      M 1 Reply Last reply
      2
      • Christian EhrlicherC Christian Ehrlicher

        It's all fine. The style is responsible on how to draw the widgets and the fusion style uses some larger elements.

        M Offline
        M Offline
        mireiner
        wrote on last edited by
        #3

        @Christian-Ehrlicher said in Controls with listboxes differ between "vista" and "fusion" style?:

        It's all fine. The style is responsible on how to draw the widgets and the fusion style uses some larger elements.

        Hello Christian,

        sorry - the "fusion" style proportions between QComboxBox and QListWiget in this example doesn't look right to me eyes.

        On Windows 10 the proportions of both control-widgets look absolutely fine. How to achieve the same uniform proportions on Linux?

        1 Reply Last reply
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          They are correct. On fusion they're different.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          M 1 Reply Last reply
          0
          • Christian EhrlicherC Christian Ehrlicher

            They are correct. On fusion they're different.

            M Offline
            M Offline
            mireiner
            wrote on last edited by
            #5

            @Christian-Ehrlicher said in Controls with listboxes differ between "vista" and "fusion" style?:

            They are correct. On fusion they're different.

            I understand that fusion style looks different. That's absolutely fine. The same if both controls would have equally larger sizes.

            The problem is the different item/menu heights of both controls. In fusion style they lose their equal size considerably. One is too large the other too small.

            Christian EhrlicherC 1 Reply Last reply
            0
            • M mireiner

              @Christian-Ehrlicher said in Controls with listboxes differ between "vista" and "fusion" style?:

              They are correct. On fusion they're different.

              I understand that fusion style looks different. That's absolutely fine. The same if both controls would have equally larger sizes.

              The problem is the different item/menu heights of both controls. In fusion style they lose their equal size considerably. One is too large the other too small.

              Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @mireiner Fusion style has different height for those two controls. Use a custom style or QProxyStyle if you don't like it.

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              M 1 Reply Last reply
              2
              • Christian EhrlicherC Christian Ehrlicher

                @mireiner Fusion style has different height for those two controls. Use a custom style or QProxyStyle if you don't like it.

                M Offline
                M Offline
                mireiner
                wrote on last edited by mireiner
                #7

                Sorry but still my personal opinion is that the larger QComboBox dimensions in fusion style is not correct und should be fixed. Expecially on Linux where fusion style is the only application style available.

                Meanwhile I found out a workaround for this issue. But don't quite understand how it works. If you change the combobox-popup style:

                comboBox->setStyleSheet("combobox-popup: 0;");
                

                The problem is gone that QComboBox dimensions are too large. And the whole QComboBox has exact the same size as QListWidget and QTreeWidget. The code works also inside Qt Designer adding following line to the stylesheet parameter of each QComboBox:

                QComboBox { combobox-popup: 0; }
                

                On other hand if you change the style to:

                comboBox->setStyleSheet("combobox-popup: 1;");
                

                The problem is back again. So the parameter "1" might stand for fusion style. But what is parameter "0" standing for on Linux? I wasn't able yet to find anything about it in the Qt documentation.

                Does this mean that the QCombobox fusion style dimension problem might be caused by a wrong internal combox-popup stylesheet assignment? To clear this question I wrote the following bug report: https://bugreports.qt.io/browse/QTBUG-89037

                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