Revision as of 04:14, 11 October 2012 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Archived:How to use QPushButton

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngArchived: 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.

Article Metadata
Tested with
Devices(s): Emulator
Platform(s): S60 3rd Edition, S60 5th Edition
Keywords: QPushButton
Created: kamaljaiswal (22 Dec 2008)
Last edited: hamishwillee (11 Oct 2012)



Push button is simply a rectangular command button with a text label printed on it. In most of the graphical user interface buttons are used to give command to computer or mobile to do certain task.


Various Function

  • Push buttons are created without text label also and later on setText() methods can be used to set the label.
QPushButton button;
  • We can also add icon to the button using the following method:
  • To disabled the button we can use
  • To set the button visualization Flat from default (3D) button. Figure given below shows that button "Hello" is flat and button "Bye" is graphical (3D)


  • For resizing the button we have the method:
  button.resize(100, 20); // first argument is width and second is the height.
  • When user click on the button, it emits different signal like clicked() when it is activated by the mouse click, pressed() or released(). This signal can be connected to the slot to perform the task.
  • Command buttons becomes the default push button automatically when they receive the focus. A default button is a push button that is activated when the user presses the Enter or Return key in a dialog. By default all the buttons are created auto default. You can change this with setAutoDefault(). Auto-default buttons needs a little extra space which is necessary to draw a default-button indicator. If you do not want this space around your buttons, call setAutoDefault( false ).
  • There are many other methods available that can be use with push button. You can get more detail on push button at


Screen Shot


QPushButton *button = new QPushButton("Quit");
QObject::connect(button, SIGNAL(clicked()),&a, SLOT(quit()));
  • Read more


Related Links

Archived:Creating Context Menu from QPushButton

This page was last modified on 11 October 2012, at 04:14.
99 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.


Thank you!

We appreciate your feedback.