Reputation: 3160
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.
Upvotes: 0
Views: 151
Reputation: 10455
You hide palette()
when you declare a variable with the same name. Use some other name, for example:
QPalette myPalette = palette();
In your snippet you have another working solution using this
:
QPalette palette = this->palette();
Upvotes: 2