#include <QtWidgets>
{
public:
explicit PageLayout
(QWidget * parent
= 0) {
pal.
setColor(QPalette::Background, Qt
::darkGray);
setPalette(pal);
setAutoFillBackground(true);
mLayout->setMargin(20);
mLayout->setSpacing(20);
}
{
page->setAutoFillBackground(true);
page
->setFixedSize
(QSize(100,
100));
mLayout->rowCount();
mLayout->addWidget(page, mLayout->rowCount() + 1, 0, 1, 1, Qt::AlignCenter);
}
private:
};
int main(int argc, char *argv[])
{
PageLayout layout;
layout.
addPage(new QLabel("Page 1"));
layout.
addPage(new QLabel("Page 2"));
layout.
addPage(new QLabel("Page 3"));
layout.
addPage(new QLabel("Page 4"));
layout.show();
return a.exec();
}
#include <QtWidgets>
class PageLayout : public QWidget
{
public:
explicit PageLayout(QWidget * parent = 0)
: QWidget(parent)
, mLayout(new QGridLayout(this))
{
QPalette pal = palette();
pal.setColor(QPalette::Background, Qt::darkGray);
setPalette(pal);
setAutoFillBackground(true);
mLayout->setMargin(20);
mLayout->setSpacing(20);
}
void addPage(QWidget * page)
{
page->setAutoFillBackground(true);
page->setFixedSize(QSize(100, 100));
mLayout->rowCount();
mLayout->addWidget(page, mLayout->rowCount() + 1, 0, 1, 1, Qt::AlignCenter);
}
private:
QGridLayout * const mLayout;
};
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
PageLayout layout;
layout.addPage(new QLabel("Page 1"));
layout.addPage(new QLabel("Page 2"));
layout.addPage(new QLabel("Page 3"));
layout.addPage(new QLabel("Page 4"));
layout.show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks