[Qt-interest] error: passing `const QLabel' as `this' argument of `void QLabel::setText(const QString&)' discards qualifiers

Paul Colby qt at colby.id.au
Sat Oct 31 00:18:19 CET 2009


QList::at() does indeed return a const T &, so that makes sense ;)

Try either of these instead:

label_list->value(i).setText("checked"); // or...
label_list[i].setText("checked"); // Might need to de-reference the
list_label pointer first?

paul.

On Sat, Oct 31, 2009 at 9:49 AM, navid navid <n_nnavid at yahoo.com> wrote:
> Hello,
>
> please comments for removing the error:
>
> void MyClass::MyFunction(QList<QCheckBox> * checkbox_list, QList<QLabel> * label_list)
> {
>    for(int i=0;i<checkbox_list->count() ;i++)
>      if (checkbox_list->at(i).checkState()){
>         label_list->at(i).setText("checked"); // error: passing `const QLabel' as `this' argument of `void QLabel::setText(const QString&)' discards qualifiers
>      }
>  }
>
>
>
> Thanks in advance
> n. navid
>
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>



-- 
http://colby.id.au




More information about the Qt-interest-old mailing list