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. Custom Table View Widget
Forum Updated to NodeBB v4.3 + New Features

Custom Table View Widget

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

    Hey guys!

    Im currently building a Bug Tracker just for fun. For that I need a custom styled QTableView. On the screenshot you can see what I want to do.
    My problem is that I dont know how I achieve this. As far as I can see I cant style the QTableView that much to fit my needs. My idea was to create the header manually (the grey bar with first name, last name etc.) and then use a QScrollArea with a custom build widget to represent the data.
    Is there a better way to do this? I need to use this custom TableView on multiple sites so a reusable widget/code would be really nice^^

    Thanks guys!

    Im using QT Widgets and C++!

    7f14a015-4cd0-40aa-af5e-ef759b366181-image.png

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      I see three possibilities:

      1. Custom QStyle or a QProxyStyle
      2. Custom QHeaderView with paintEvent re-implemented
      3. Qt Stylesheet system

      There's no particular order of preferences.

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

      V 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        I see three possibilities:

        1. Custom QStyle or a QProxyStyle
        2. Custom QHeaderView with paintEvent re-implemented
        3. Qt Stylesheet system

        There's no particular order of preferences.

        V Offline
        V Offline
        VogelPapaFinn
        wrote on last edited by
        #3

        @SGaist
        1 - So I create a new "app style" which defines how the TableView gets drawn? So I work with e.g. a Painter and other stuff related to drawing/displaying things?

        2 - Im replacing the QTableView header with a custom one which gets styled via stylesheet? And the TableView itself is redesigned via overwritting how it gets drawn/displayed?

        3 - I tried that but I only had very limited options to style the TableView. Or what exactly do you mean with that?

        Never worked with any of these (except stylesheet ofc) so I dont know them. Sorry for asking^^

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Not the table view, the QHeaderView.

          For the styling, see KDAB's Say No To Qt Style Sheets.

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

          V 1 Reply Last reply
          0
          • SGaistS SGaist

            Not the table view, the QHeaderView.

            For the styling, see KDAB's Say No To Qt Style Sheets.

            V Offline
            V Offline
            VogelPapaFinn
            wrote on last edited by
            #5

            @SGaist Never thought about these things. Seems like QStyle is by far the better choice. The only thing that is holding me back is the QT-Designer. Atm Im using VS22 with the Qt Tools. My problem is that I need to recompile and rerun the program everytime I change something small + I cant "preview" it in the Designer. Or am I wrong?
            For me it looks like I shift more and more to bare C++ code until every small peace of ui stuff is coded. It makes .ui files more or less useless. You know what I mean?

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              I see what you mean.

              From memory, Designer allows to preview your design in different styles but I don't know how to make it use your own style beside the fact that you would need to build it with the same Qt version that was used to build designer.

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

              V 1 Reply Last reply
              0
              • SGaistS SGaist

                I see what you mean.

                From memory, Designer allows to preview your design in different styles but I don't know how to make it use your own style beside the fact that you would need to build it with the same Qt version that was used to build designer.

                V Offline
                V Offline
                VogelPapaFinn
                wrote on last edited by
                #7

                @SGaist So its a needed sacrifice? Or am I missing something?

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Not necessarily, I currently just don't know how to make your custom style available to be used by Designer for preview.

                  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

                  • Login

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