You Are Here:

Community: Wiki

This page was last modified on 11 November 2009, at 16:52.

How to use QPushButton in Qt for Symbian

From Forum Nokia Wiki

Reviewer Approved   



ID Creation date 22 December 2008
Platform S60 3rd Edition, S60 5th Edition Tested on devices Emulator
Category Qt for Symbian Subcategory Push buttons


Keywords (APIs, classes, methods, functions): QPushButton

Overview

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.

Preconditions

Various Function

  • Push buttons are created without text label also and later on setText() methods can be used to set the label.
 QPushButton button;
 button.setText("hello");
  • We can also add icon to the button using the following method:
 button.setIcon("c://icon.jpg");
  • To disabled the button we can use
 button.setDisabled(true);
  • 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)
button.setFlat(1);

Image:FlatButton.JPG

  • For resizeing 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).
 button.setAutoDefault(false);
  • There are many other methods available that can be use with push button. You can get more detail on push button at

http://pepper.troll.no/s60prereleases/doc/qpushbutton.html

Screen Shot

Image:QPushButton.JPG

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

QPushButton

Related Links

Creating Menu from QPushButton



This article shows the method of the Button like icon setting, enable disabled mode. I think in every application where button is used , this example is very useful.


$

[--Fasttrack 19:29, 11 September 2009 (UTC)]


Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fHowE5ftoE5fsendE5fandE5freceiveE5fmessagesE5finE5fE51tE5fforE5fSymbianX qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqfntypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZE71tQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZtypeQUqfntypeZWikiContentQ qfnZuserE5ftagQSxE71tX qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqfntypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ