Archived:Creating Context Menu from QPushButton
hamishwillee
(Talk | contribs) m (Added category Category:Symbian. (Preparing for ontology change)) |
hamishwillee
(Talk | contribs) m (Remove platform specifier categories (only need specifier for Qt if there is some platform specific behaviour)) |
||
| Line 1: | Line 1: | ||
| + | [[Category:Qt]][[Category:UI]] | ||
{{ReviewerApproved}} | {{ReviewerApproved}} | ||
| Line 5: | Line 6: | ||
|platform=S60 3rd Edition, S60 5th Edition | |platform=S60 3rd Edition, S60 5th Edition | ||
|devices=Emulator | |devices=Emulator | ||
| − | |category=Qt | + | |category=Qt |
|subcategory= UI | |subcategory= UI | ||
|creationdate= 27 June 2009 | |creationdate= 27 June 2009 | ||
| Line 11: | Line 12: | ||
}} | }} | ||
| − | |||
==Introduction== | ==Introduction== | ||
| Line 17: | Line 17: | ||
This turns the button into a menu button, which in some styles will produce a small triangle to the right of the button's text. | This turns the button into a menu button, which in some styles will produce a small triangle to the right of the button's text. | ||
| − | |||
| − | |||
| − | |||
==Source Code== | ==Source Code== | ||
| Line 56: | Line 53: | ||
==Related Links== | ==Related Links== | ||
| − | * [[How_to_use_QPushButton_(Qt_for_Symbian)|How to use QPushButton]] [[Category: | + | * [[How_to_use_QPushButton_(Qt_for_Symbian)|How to use QPushButton]] |
| + | |||
| + | [[Category:S60]][[Category:How To]][[Category:Code Examples]] | ||
Revision as of 13:26, 4 April 2011
Article Metadata
Tested with
Devices(s): Emulator
Compatibility
Platform(s): S60 3rd Edition, S60 5th Edition
Article
Keywords: QPushButton
Created: (27 Jun 2009)
Last edited: hamishwillee
(04 Apr 2011)
Contents |
Introduction
Associates the popup menu menu with this push button.
This turns the button into a menu button, which in some styles will produce a small triangle to the right of the button's text.
Source Code
Source File
#include "button.h"
#include "ui_button.h"
button::button(QWidget *parent)
: QWidget(parent)
{
win=new QWidget(this);
win->resize(400,500);
lay=new QHBoxLayout(this);
menu=new QMenu(this);
menu->addMenu("Nokia");
menu->addMenu("N96");
menu->addMenu("N97");
but1=new QPushButton("Menu",this);
but1->setMenu(menu);
lay->addWidget(but1);
win->setLayout(lay);
win->setStyleSheet("* { background-color:rgb(125,100,50);color:rgb(200,150,100); padding: 7px}}");
}
button::~button()
{
// No need to delete any object that has a parent which is properly deleted.
}
Screenshot


