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. Multiple views based on same model, with different columns

Multiple views based on same model, with different columns

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 1.8k Views 1 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.
  • F Offline
    F Offline
    frankiefrank
    wrote on last edited by
    #1

    I have some data stored in a table-like model (a subclass of QAbstractTableModel), but I want to end up displaying this data in several views - with some difference in the way it is displayed, while making sure selection makes sense.

    For example, if one of my columns is a 10 character string, I want to have one view where that string is displayed as a single column, but another view where it is displayed as two columns, each one 5 characters long. And another with 5 columns, each one 2 characters long. I also want to make sure that selection works across the different views. Like, if you select a column with a small part of the string, the other views show the relevant cells as selected.

    I'm not sure if this calls for use of the proxy model system or if there is some other way to manipulate the views via the selection model. I'd appreciate any input - especially if I'm off and there's a clearer path.

    "Roads? Where we're going, we don't need roads."

    1 Reply Last reply
    0
    • F Offline
      F Offline
      frankiefrank
      wrote on last edited by
      #2

      Sad bump - can anyone help out?

      "Roads? Where we're going, we don't need roads."

      1 Reply Last reply
      0
      • F Offline
        F Offline
        frankiefrank
        wrote on last edited by
        #3

        If anyone has any thoughts on this - still interested.

        "Roads? Where we're going, we don't need roads."

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

          Hi,

          You would need one configurable proxy per view e.g. configure the number of colon and in data split the data as needed.

          As for you special selection, you might need to combine your selection model with QStyledItemDelegate where you reimplement the paint function and draw the selection rectangle yourself.

          Hope it helps

          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
          • F Offline
            F Offline
            frankiefrank
            wrote on last edited by
            #5

            The use of the proxy with modifying the column count is a great pointer.

            I may end up resolving the whole issue with a different approach to the UI but great to know and thanks a lot for writing.

            "Roads? Where we're going, we don't need roads."

            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