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. Dropdown with the QTableView
Forum Updated to NodeBB v4.3 + New Features

Dropdown with the QTableView

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 294 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.
  • V Offline
    V Offline
    vijaychsk
    wrote on last edited by
    #1

    Hi,
    I have a QTableView that works as expected. But it is taking up too much space.
    For example, my data looks like this. As you can see, each row is correct and has some data. The rows pt1 .... pt100 are simply increasing the overall number of rows in the table. It is getting hard when scrolling within my main window.

    If I can identify the group pt and estimate its size say 5 or 10 or 50 or 100 then how do I group all the pt* rows or keep a expand/collapse button for some rows such as pt within the QTableView?

    +---------+------+----+-----+
    | Name    | Type | ID | eID |
    +---------+------+----+-----+
    | fast    |      |    |     |
    +---------+------+----+-----+
    | quick   |      |    |     |
    +---------+------+----+-----+
    | observe |      |    |     |
    +---------+------+----+-----+
    | pt1     |      |    |     |
    +---------+------+----+-----+
    | pt2     |      |    |     |
    +---------+------+----+-----+
    | pt3     |      |    |     |
    +---------+------+----+-----+
    | pt4     |      |    |     |
    +---------+------+----+-----+
    | pt5     |      |    |     |
    +---------+------+----+-----+
    | ...     |      |    |     |
    +---------+------+----+-----+
    | pt100   |      |    |     |
    +---------+------+----+-----+
    
    JonBJ 1 Reply Last reply
    0
    • V vijaychsk

      Hi,
      I have a QTableView that works as expected. But it is taking up too much space.
      For example, my data looks like this. As you can see, each row is correct and has some data. The rows pt1 .... pt100 are simply increasing the overall number of rows in the table. It is getting hard when scrolling within my main window.

      If I can identify the group pt and estimate its size say 5 or 10 or 50 or 100 then how do I group all the pt* rows or keep a expand/collapse button for some rows such as pt within the QTableView?

      +---------+------+----+-----+
      | Name    | Type | ID | eID |
      +---------+------+----+-----+
      | fast    |      |    |     |
      +---------+------+----+-----+
      | quick   |      |    |     |
      +---------+------+----+-----+
      | observe |      |    |     |
      +---------+------+----+-----+
      | pt1     |      |    |     |
      +---------+------+----+-----+
      | pt2     |      |    |     |
      +---------+------+----+-----+
      | pt3     |      |    |     |
      +---------+------+----+-----+
      | pt4     |      |    |     |
      +---------+------+----+-----+
      | pt5     |      |    |     |
      +---------+------+----+-----+
      | ...     |      |    |     |
      +---------+------+----+-----+
      | pt100   |      |    |     |
      +---------+------+----+-----+
      
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @vijaychsk
      Quite simply I think this would be "hard". QTableView has no support for "grouping", "expanding" or "collapsing", so you would have to code all the logic yourself. Not that it cannot be done, but I would guess it would require "substantial" coding.

      A possible alternative would be to remodel as a QTreeView. This at least has support for parent/child nodes so that you can group/expand/collapse. But it still would not be easy: the rows other than the pt* ones do not form parent/children, so you would have to shoehorn something in to work.

      D 1 Reply Last reply
      0
      • JonBJ JonB

        @vijaychsk
        Quite simply I think this would be "hard". QTableView has no support for "grouping", "expanding" or "collapsing", so you would have to code all the logic yourself. Not that it cannot be done, but I would guess it would require "substantial" coding.

        A possible alternative would be to remodel as a QTreeView. This at least has support for parent/child nodes so that you can group/expand/collapse. But it still would not be easy: the rows other than the pt* ones do not form parent/children, so you would have to shoehorn something in to work.

        D Offline
        D Offline
        DerReisende
        wrote on last edited by
        #3

        @JonB Wouldn’t be a QSortFilterProxyModel sufficient to fulfill the „grouping“ requirement by sorting the rows based on pt size?

        JonBJ 1 Reply Last reply
        0
        • D DerReisende

          @JonB Wouldn’t be a QSortFilterProxyModel sufficient to fulfill the „grouping“ requirement by sorting the rows based on pt size?

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @DerReisende
          Yes they would be consecutive, but how would that equate to any kind of "group node" in a QTableView which is "flat", and has no support for any kind of "grouping"?

          Besides which, there is no evidence there is any kind of "sorting by pt*" requested by the OP. These are rows. They are simply (apparently) always to be there, in pt1..100 order, no "sorting", "comparing" or "totalling" of any kind, no suggestion that only some are present. Unless OP has some quite different specification for what they are which has not been stated.

          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