How to get the position of the spanned cell in QGridLayout
-
I am working with QGridLayout, my grid will contain items of unequal size and I use QGridLayout's spanRow spanCol property to do that.
And the problem I'm facing is that I want to get the position of span rows or span cols on the grid to display data on the entire item, and I don't know how to do it, does anyone have any ideas? ? Please help me.
I have an example, the following picture illustrates that the second column of the first row spans two columns and the second row of the second column spans two rows. How to get the position of spanned cells (1, 0) and (1,1) as shown in the picture.Currently, I have merged the cells into one large cell, but when I use a for loop, it still shows the index of the small cells. How can I use 1 index for that large cell only? My spanned cell is in the center of the grid layout
-
@Hai-Anh-Luu
I believe items are numbered from 0 ascending, presumably left-to-right then top-to-bottom, you can test? Some combination ofgetItemPosition()
,itemAt()
,itemAtPositon()
? -
@Hai-Anh-Luu
I am not sure quite what you are looking for. Have you seen
void QGridLayout::getItemPosition(int index, int *row, int *column, int *rowSpan, int *columnSpan) const, what gives you back span information for an item from an index? -
@JonB Hi Jon, i don't understand how to use getItemPosition. For example, the following image is my current grid, how to get position of Large 0 0 and Large 0 . I cannot determine the index of Large 0 0 and 0 2 to use the getItemPosition function.
-
@Hai-Anh-Luu
I believe items are numbered from 0 ascending, presumably left-to-right then top-to-bottom, you can test? Some combination ofgetItemPosition()
,itemAt()
,itemAtPositon()
? -
@Hai-Anh-Luu One simple way to get index is using
QLayout::indexOf(QWidget *widget)
-