Archived:如何显示正常和最大尺寸的widget
文章信息
示例代码
#include <QApplication>
#include <QPushButton>
#include <QVBoxLayout>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
// win is the top level widget
QWidget win;
QVBoxLayout* layout = new QVBoxLayout(&win);
// This button show the top level widget in a normal size
QPushButton* normalSizeButton = new QPushButton("Normal size");
QObject::connect(normalSizeButton, SIGNAL(clicked()), &win, SLOT(showNormal()));
layout->addWidget(normalSizeButton);
// This button maximize the widget size
QPushButton* maximzeButton = new QPushButton("Maximize");
QObject::connect(maximzeButton, SIGNAL(clicked()), &win, SLOT(showMaximized()));
layout->addWidget(maximzeButton);
// This button exit the application
QPushButton* exitButton = new QPushButton("Exit");
QObject::connect(exitButton, SIGNAL(clicked()), &app, SLOT(quit()));
layout->addWidget(exitButton);
win.show(); // show the top level widget
return app.exec(); // start the event loop
}
当点击Normal Size后的输出




(no comments yet)