[SOLVED] Error with setRect in QRect
-
Hello all!
I have a QRect and when I try to setRect it return this error
/QT/Projetos/VisaoFinanceira/fluxocaixawidget.cpp:174: error: member function 'setRect' not viable: 'this' argument has type 'const QRect', but function is not marked const
fluxoRect.at(i).setRect(7,7,7,7);Thanks.
Here is the code:
@
QList<QRect> fluxoRect;fluxoRect.append(QRect(0,0,0,0));
fluxoRect.at(i).setRect(7,7,7,7);
@ -
Hey,
look at the definition of the at method:
const T & at(int i) constQList returns a const reference to your QRect, hence you're not allowed to alter it.
You have to do something like this:
@ QList<QRect> fluxoRect;fluxoRect.append(QRect(0,0,0,0)); QRect r = fluxoRect.takeAt(i); r.setRect(7, 7, 7, 7); fluxoRect.replace(i, r);@
bb
-
Hi,
at is a constant function so you can't modify it's returned value like that.
Either use the value method or the [] operator.
You can also take the rect modify it and replace the original value with the new value.
Hope it helps
-
Thank you for the replies Saugglocke and SGaist
It worked.
@
fluxoRect.at(i).replace(QRect(7,7,7,7));
@