Namespaces
Variants
Actions

Archived:How to display a widget with normal and maximize size in Qt

Jump to: navigation, search
Archived.png
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.

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
}

Output after clicking on Normal Size

Normalsize.jpg

Output after clicking on maximize

Maximize.jpg

This page was last modified on 11 October 2012, at 04:13.
458 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved