{
public:
protected:
signals:
void sizeChange
(QSize size
);
};
class QCustomResizeWidget
: QFrame{
public:
QCustomResizeWidget
(QWidget *parent
) public slots:
void sizeChangeSlot
(QSize size
);
};
class QCustomMainPage : QWidget
{
public:
QCustomMainPage(QWidget *parent)
protected:
void resizeEvent ( QResizeEvent *re );
signals:
void sizeChange(QSize size);
};
class QCustomResizeWidget : QFrame
{
public:
QCustomResizeWidget (QWidget *parent)
public slots:
void sizeChangeSlot(QSize size);
};
To copy to clipboard, switch view to plain text mode
QCustomResizeWidget
::QCustomResizeWidget(QWidget *parent
):QFrame (parent
){ clayout->addWidget(label1);
clayout->addWidget(label2);
}
void QCustomResizeWidgetsize
::ChangeSlot(QSize size
){ this
->setFixedSize
(QSize(size.
width()/10, size.
height()/10));
}
QCustomResizeWidget *customwidget1 = new QCustomResizeWidget;
connect(this,
SIGNAL(sizeChange
(QSize)), customwidget1,
SLOT(ChangeSlot
(QSize)));
QCustomResizeWidget *customwidget2 = new QCustomResizeWidget;
connect(this,
SIGNAL(sizeChange
(QSize)), customwidget2,
SLOT(ChangeSlot
(QSize)));
QCustomResizeWidget *customwidget3 = new QCustomResizeWidget;
connect(this,
SIGNAL(sizeChange
(QSize)), customwidget3,
SLOT(ChangeSlot
(QSize)));
QCustomResizeWidget *customwidget4 = new QCustomResizeWidget;
connect(this,
SIGNAL(sizeChange
(QSize)), customwidget4,
SLOT(ChangeSlot
(QSize)));
QCustomResizeWidget *customwidget5 = new QCustomResizeWidget;
connect(this,
SIGNAL(sizeChange
(QSize)), customwidget5,
SLOT(ChangeSlot
(QSize)));
QCustomResizeWidget *customwidget6 = new QCustomResizeWidget;
connect(this,
SIGNAL(sizeChange
(QSize)), customwidget6,
SLOT(ChangeSlot
(QSize)));
hboxlayout->addStretch(1); // push widgets to the right
hbox->addWidget(customwidget5, 1) // remember stretch
hbox->addWidget(customwidget6, 1) // remember stretch
grid->addWidget(customwidget1, 0,0);
grid->addWidget(customwidget2, 0,1);
grid->addWidget(customwidget3, 1,0);
grid->addWidget(customwidget4, 1,1);
mainlayout->addLayout(hbox);
mainlayout->addLayout(grid);
}
emit sizeChange(re->size());
}
QCustomResizeWidget::QCustomResizeWidget(QWidget *parent):QFrame (parent){
QLabel *label1 = new QLabel("label1");
QLabel *label2 = new QLabel("label2");
QVBoxLayout *clayout = new QVBoxLayout(this);
clayout->addWidget(label1);
clayout->addWidget(label2);
}
void QCustomResizeWidgetsize::ChangeSlot(QSize size){
this->setFixedSize(QSize(size.width()/10, size.height()/10));
}
QCustomMainPage::QCustomMainPage(QWidget *parent) : QWidget(parent){
QCustomResizeWidget *customwidget1 = new QCustomResizeWidget;
connect(this, SIGNAL(sizeChange(QSize)), customwidget1, SLOT(ChangeSlot(QSize)));
QCustomResizeWidget *customwidget2 = new QCustomResizeWidget;
connect(this, SIGNAL(sizeChange(QSize)), customwidget2, SLOT(ChangeSlot(QSize)));
QCustomResizeWidget *customwidget3 = new QCustomResizeWidget;
connect(this, SIGNAL(sizeChange(QSize)), customwidget3, SLOT(ChangeSlot(QSize)));
QCustomResizeWidget *customwidget4 = new QCustomResizeWidget;
connect(this, SIGNAL(sizeChange(QSize)), customwidget4, SLOT(ChangeSlot(QSize)));
QCustomResizeWidget *customwidget5 = new QCustomResizeWidget;
connect(this, SIGNAL(sizeChange(QSize)), customwidget5, SLOT(ChangeSlot(QSize)));
QCustomResizeWidget *customwidget6 = new QCustomResizeWidget;
connect(this, SIGNAL(sizeChange(QSize)), customwidget6, SLOT(ChangeSlot(QSize)));
QHBoxLayout *hbox = new QHBoxLayout();
hboxlayout->addStretch(1); // push widgets to the right
hbox->addWidget(customwidget5, 1) // remember stretch
hbox->addWidget(customwidget6, 1) // remember stretch
QGridLayout *grid = new QGridLayout();
grid->addWidget(customwidget1, 0,0);
grid->addWidget(customwidget2, 0,1);
grid->addWidget(customwidget3, 1,0);
grid->addWidget(customwidget4, 1,1);
QVBoxLayout *mainlayout = QVBoxLayout(this);
mainlayout->addLayout(hbox);
mainlayout->addLayout(grid);
}
QCustomMainPage::resizeEvent(QResizeEvent *re ){
emit sizeChange(re->size());
}
To copy to clipboard, switch view to plain text mode
Bookmarks