Dropdown with the QTableView
-
Hi,
I have aQTableViewthat 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 rowspt1 .... pt100are 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
ptand estimate its size say5 or 10 or 50 or 100then how do I group all thept*rows or keep a expand/collapse button for some rows such asptwithin theQTableView?+---------+------+----+-----+ | Name | Type | ID | eID | +---------+------+----+-----+ | fast | | | | +---------+------+----+-----+ | quick | | | | +---------+------+----+-----+ | observe | | | | +---------+------+----+-----+ | pt1 | | | | +---------+------+----+-----+ | pt2 | | | | +---------+------+----+-----+ | pt3 | | | | +---------+------+----+-----+ | pt4 | | | | +---------+------+----+-----+ | pt5 | | | | +---------+------+----+-----+ | ... | | | | +---------+------+----+-----+ | pt100 | | | | +---------+------+----+-----+ -
Hi,
I have aQTableViewthat 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 rowspt1 .... pt100are 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
ptand estimate its size say5 or 10 or 50 or 100then how do I group all thept*rows or keep a expand/collapse button for some rows such asptwithin theQTableView?+---------+------+----+-----+ | Name | Type | ID | eID | +---------+------+----+-----+ | fast | | | | +---------+------+----+-----+ | quick | | | | +---------+------+----+-----+ | observe | | | | +---------+------+----+-----+ | pt1 | | | | +---------+------+----+-----+ | pt2 | | | | +---------+------+----+-----+ | pt3 | | | | +---------+------+----+-----+ | pt4 | | | | +---------+------+----+-----+ | pt5 | | | | +---------+------+----+-----+ | ... | | | | +---------+------+----+-----+ | pt100 | | | | +---------+------+----+-----+@vijaychsk
Quite simply I think this would be "hard".QTableViewhas 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 thept*ones do not form parent/children, so you would have to shoehorn something in to work. -
@vijaychsk
Quite simply I think this would be "hard".QTableViewhas 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 thept*ones do not form parent/children, so you would have to shoehorn something in to work.@JonB Wouldn’t be a
QSortFilterProxyModelsufficient to fulfill the „grouping“ requirement by sorting the rows based on pt size? -
@JonB Wouldn’t be a
QSortFilterProxyModelsufficient to fulfill the „grouping“ requirement by sorting the rows based on pt size?@DerReisende
Yes they would be consecutive, but how would that equate to any kind of "group node" in aQTableViewwhich 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, inpt1..100order, 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.