PDA

View Full Version : QScrollArea, QPalette



spyral
12th September 2014, 12:57
Hello, everyone.
I'm new to Qt-programming and have the following problem:



MyClassConstructor::MyClassConstructor( QWidget* parent )
: QWidget( parent )
{
QScrollArea* area = new QScrollArea;
QWidget* w = new QWidget;

QVBoxLayout* layout = new QVBoxLayout;
layout->addWidget( area );

w->resize( 500, 500 );
QPalette p( m_table->palette() );
p->setColor( QPalette::Window, Qt::red );

area->setWidget( w );
area->viewport()->setAutoFillBackground( true );
// area->viewport()->setStyleSheet( "QWidget{background:green}" );
area->viewport()->setPalette( p );

this->setLayout( layout );
}


If I uncomment the line with setStyleSheet, the widget is wonderful red. But using the QPalette won't give a result.
What is thing, I do not understand?
I'm new here, so I hope I respect the rules of the forum.
Thank you.