Reputation: 159
The follow snippet results in my compilation yielding "error: passing 'const QRect' as 'this' argument of 'void QRect::setHeight(int)' discards qualifiers [-fpermissive]".
How can I fix this and also I've noticed that if I were to replace h -= 80; with h--;, the compiler does not complain.
int h = this->geometry().height();
h -= 80;
ui->datumTable->geometry().setHeight(h);
Upvotes: 1
Views: 991
Reputation: 84972
geometry()
returns a const reference to a QRect
object inside QTableWidget
.
It's meant to be a read-only getter. You should take a copy, modify it and set it back with setGeometry
setter function:
QRect rect = this->geometry();
int h = rect.height();
rect.setHeight(h - 80);
ui->datumTable->setGeometry(rect);
Upvotes: 2
Reputation: 5738
QRect g = this->geometry().height();
g.setHeight(g.height()-80);
ui->datumTable->setGeometry(g);
Upvotes: 1
Reputation: 129524
It would seem that geometry()
in datumTable
returns a const QRect
. Not an easy fix unless there is a non-const version as well.
Upvotes: 0