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. [C++] QTableView, how to remove cell padding?
Forum Updated to NodeBB v4.3 + New Features

[C++] QTableView, how to remove cell padding?

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 6 Posters 684 Views 3 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 Offline
    A Offline
    Alhazred
    wrote on last edited by
    #1

    Hello,
    I have bought a new PC where I have installed a new environment and with the exact same code I get a different UI visualization as you can see in the image at the end of the message.
    The cells are now shown with some padding and rounded borders.

    As IDE I use VisualStudio 2022 on both PCs.

    The differences between the two environments are:
    Windows SDK 10 for the old, 11 for the new
    Qt 6.2 for the old, 6.7 for the new.

    Which of those is responsible for the visualization difference?
    Would I want to stay updated and going on with the newer versions, how do I get rid of the paddings and rounded corners?
    I'm not able to find any method, both in QTableView and QTableWidget, to manage those aspects.

    Both of the screenshots have been taken running the software on the new PC, but the first is a version compiled on the old PC with the old environment, the second is compiled on the new PC with the updated environment, using the same code.

    alt text

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

      Qt 6.7 got a new theme for windows 11. Start your app with the windowsvista theme (-style windowsvista) to get the old windows 10 theme.

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

      A 1 Reply Last reply
      0
      • cristian-adamC Offline
        cristian-adamC Offline
        cristian-adam
        wrote on last edited by
        #3

        If you think it's a bug, do report it at https://bugreports.qt.io/

        S 1 Reply Last reply
        0
        • Christian EhrlicherC Christian Ehrlicher

          Qt 6.7 got a new theme for windows 11. Start your app with the windowsvista theme (-style windowsvista) to get the old windows 10 theme.

          A Offline
          A Offline
          Alhazred
          wrote on last edited by
          #4

          @Christian-Ehrlicher said in [C++] QTableView, how to remove cell padding?:

          Qt 6.7 got a new theme for windows 11. Start your app with the windowsvista theme (-style windowsvista) to get the old windows 10 theme.

          Do you mean as a parameter to add to the executable file?

          SGaistS 1 Reply Last reply
          0
          • A Alhazred

            @Christian-Ehrlicher said in [C++] QTableView, how to remove cell padding?:

            Qt 6.7 got a new theme for windows 11. Start your app with the windowsvista theme (-style windowsvista) to get the old windows 10 theme.

            Do you mean as a parameter to add to the executable file?

            SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @Alhazred hi

            Yes, as a parameter of the application.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • cristian-adamC cristian-adam

              If you think it's a bug, do report it at https://bugreports.qt.io/

              S Offline
              S Offline
              SimonSchroeder
              wrote on last edited by
              #6

              @cristian-adam said in [C++] QTableView, how to remove cell padding?:

              If you think it's a bug, do report it at https://bugreports.qt.io/

              I would be careful with calling this a bug. Qt tries to use the default OS theme if possible. Sometimes they just lack behind a little bit. If the new Windows style is what we see with Qt 6.7, it is a choice of Microsoft and not of Qt. In general it is a good idea to have your own app a) look modern and b) look like all the other apps people might install. You might disagree with the design choices of Microsoft, but it is still a good idea to go along with it. (Disclaimer: I don't know if the design of Qt 6.7 is actually a design change of Windows.)

              However, if you insist on changing it by yourself: If you have a QTableWidget you can get the individual QTableWidgetItems. My guess is that these need to be styled. The easiest (and most reliable way in Qt) is to use stylesheets (most likely a single style sheet for the QTableWidget just styling the QTableWidgetItems will do). You can also have a look at QStyleItemDelegate to change the look of the cells.

              1 Reply Last reply
              0
              • A Offline
                A Offline
                Alhazred
                wrote on last edited by
                #7

                I am willing to use the css way. Is there a list of the available selectors for the QTableView?
                Reading the docuementation I can only find a few as example.

                Pl45m4P 1 Reply Last reply
                0
                • A Alhazred

                  I am willing to use the css way. Is there a list of the available selectors for the QTableView?
                  Reading the docuementation I can only find a few as example.

                  Pl45m4P Offline
                  Pl45m4P Offline
                  Pl45m4
                  wrote on last edited by
                  #8

                  @Alhazred said in [C++] QTableView, how to remove cell padding?:

                  Reading the docuementation I can only find a few as example

                  It supports the ones it claims to support :)
                  Note: Qt StyleSheet is not fully CSS. Not everything is possible with Qt StyleSheet.


                  If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                  ~E. W. Dijkstra

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    Alhazred
                    wrote on last edited by
                    #9

                    I couldn't get the wanted visual result using code and css.
                    I've decided to solve using the "-style windowsvista" parameter as suggested.
                    The software is in use internally to the company where I work, I will not distribute it.

                    1 Reply Last reply
                    0
                    • A Alhazred has marked this topic as solved on

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved