Cannot use QRect::setWidth
When I try to set the width of a modified QDockWidget
Code:
int iWidth = 500;
this->geometry().setWidth(iWidth);
I get the following error.
Quote:
passing 'cost QRect' as 'this' argument of 'void QRect::setWidth(int)' discards qualifier
I have no idea what that error means and why I can't use such a simple function.
Re: Cannot use QRect::setWidth
It means you are trying to modify an object that is const.
Re: Cannot use QRect::setWidth
Quote:
passing 'const QRect' as 'this' argument of 'void QRect::setWidth(int)' discards qualifier
Contains two clues. You have a constant object that you are trying to use a non-const method on. The "discards qualifier" refers to attempting to discard the "const". This is an error and basic C++.
QWidget::geometry() is defined:
Code:
const QRect & geometry
() const
You cannot modify a const QRect.
You can modify the geometry through the QWidget::setGeometry() method.
Re: Cannot use QRect::setWidth
Thank you,
that was really stupid...
When I read your post I remembered that I used setGeometry() before.