Archived:How to display a widget with normal and maximize size in Qt
Archived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.
Qt Quick should be used for all UI development on mobile devices. The approach described in this article (based on QWidget) is deprecated.
Qt Quick should be used for all UI development on mobile devices. The approach described in this article (based on QWidget) is deprecated.
In this article we will create three button widgets with QPushButton and display two of them in Normal and Maximum size. QWidget::showNormal () slot is used to restores the widget after it has been maximized or minimized and QWidget::showMinimized () is used to shows the widget minimized. The third button Exit calls quit() slot to exit out from the application.
Article Metadata
Tested with
Devices(s): Emulator
Compatibility
Platform(s): S60 3rd Edition, S60 5th Edition
Article
Keywords: QVBoxLayout,QHBoxLayout
Created: james1980
(28 Dec 2008)
Last edited: hamishwillee
(11 Oct 2012)
Code
#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
}




14 Sep
2009
28 Sep
2009