Reputation: 328
So i have been trying to use QGridLayout for a while and it keeps giving me the error: "error: no matching function for call to 'QLayout::addWidget(QScrollArea*, int, int)". I have no idea what am I doing wrong. Here is the part of the code which seems to be causing the error:
QScrollArea * setScrollArea(QWidget * w)
{
w->setStyleSheet("background-color:white;");
QScrollArea * scrollArea = new QScrollArea;
scrollArea->setWidgetResizable(true);
scrollArea->setWidget(w);
return scrollArea;
} ^
.
.
.
shower = new QWidget;
shower->setLayout(new QGridLayout);
shower->layout()->addWidget(setScrollArea(upWindow), 0, 0);
shower->layout()->addWidget(setScrollArea(downWindow), 1, 0);
Does anyone have an idea, what am i doing wrong?
Upvotes: 2
Views: 1400
Reputation: 1229
QWidget::layout()
returns a simple QLayout
that has no function addWidget( QWidget *, int, int )
.
To use the QGridLayout
functionality, do the following:
shower = new QWidget;
QGridLayout * layout = new QGridLayout;
layout->addWidget(setScrollArea(upWindow), 0, 0);
layout->addWidget(setScrollArea(downWindow), 1, 0);
shower->setLayout(layout);
Upvotes: 4