mardi 21 avril 2015

no match for call to '(QPalette)()' Qt4 in Linux

When I compiled an example code in QtCreator3.3.2 with Qt4.8.6 in Ubuntu14.04, this following error occurred:

videowidget.cpp:19: error: no match for call to '(QPalette) ()'
     palette = palette();
                       ^

in this snippet:

VideoWidget::VideoWidget(QWidget *parent) : QWidget(parent),surface(0)
{   
    setAutoFillBackground(false);
    setAttribute(Qt::WA_NoSystemBackground,true);
    setAttribute(Qt::WA_PaintOnScreen,true);

    palette = this->palette();//here's the error 
    palette.setColor(QPalette::Background,Qt::black);
    setPalette(palette);
    setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::MinimumExpanding);
    surface = new VideoWidgetSurface(this);
}

I looked up QPlalette class and QWidget class in Qt Assistant and manual of QWidget says:

Access functions:

const QPalette & palette () const

void setPalette ( const QPalette & )

which seems to me that QWidget has palette() function and so VideoWidget will definitely have it. But such error comes out. Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire