Archived:Creating Context Menu from QPushButton
Article Metadata
Tested with
Devices(s): 5800 Xpress Muzic
Compatibility
Platform(s): S60 3rd Edition, S60 5th Edition
Article
Keywords: QPushButton
Created: (27 Jun 2009)
Last edited: mind_freak
(27 Jul 2009)
Contents |
Introdction
Program shows the menu generated when button is pressed.
Preconditions
- Install Qt for S60 Tower release from here: Qt for S60 "Tower" pre-release
- Check this link for installation guide: How to install the package.
- Download Qt creator IDE:QtIDEv4.5
Source Code
Source File
#include "button.h"
#include "ui_button.h"
button::button(QWidget *parent)
: QWidget(parent)
{
lay=new QHBoxLayout();
menu=new QMenu();
menu->addMenu("Nokia");
menu->addMenu("N96");
menu->addMenu("N97");
but1=new QPushButton("Menu");
but1->setMenu(menu);
lay->addWidget(but1);
setLayout(lay);
}
button::~button()
{
if(menu)
{
delete menu;
}
if(but1)
{
delete but1;
}
if(lay)
{
delete lay;
}
}
Screenshot

