Get QTableWidget Cell width and height
Hi everyone,
I want to resize a QLabel(in the labels are images) to fit in a cell. I use
Code:
label->setFixedSize(ui->tableWidget->columnWidth(currentColumn),ui->tableWidget->rowHeight(currentRow));
to set the labels size and than
Code:
label->setPixmap(p.scaled(label->width(),label->height(),Qt::KeepAspectRatio));
to keep the image aspect ratio. I get the currentColumn/Row from a selectionmodel.
When the cell doesn´t have row/colspan all works fine. But when i span (for example 2 rows) then i only get the height of the first row and i want to get the height of r1+r2. So the Image only fit the size of the first cell before the span and ignores the additional size from the span.
I didn´t find something about cellwidth/cellheight so I´m asking here now.
(And sorry for my bad english)
Re: Get QTableWidget Cell width and height
Probably need to call the base class QTableWidget::rowSpan() and/or QTableWidget::columnSpan() methods and then query for the heights / widths of the additional rows if either method returns > 1.
Re: Get QTableWidget Cell width and height
I can't find these methods...
Re: Get QTableWidget Cell width and height
Sorry, I miss-typed. I meant QTableView. Always look in the base classes for functionality that is "missing" from the class you are instantiating.
Re: Get QTableWidget Cell width and height
Ok i'll try and reply after
Re: Get QTableWidget Cell width and height
can you post an example of how to use this? i don´t know how to get to the parent´s method.
Re: Get QTableWidget Cell width and height
You just call them like any other method.
A QTableWidget is a QTableView.
Cheers,
_