×
Namespaces

Variants
Actions
(Difference between revisions)

Archived:Creating Context Menu from QPushButton

From Nokia Developer Wiki
Jump to: navigation, search
mind_freak (Talk | contribs)
savaj (Talk | contribs)
(added QPushButton to object trees to cleanup properly.)
Line 34: Line 34:
 
   menu->addMenu("N96");
 
   menu->addMenu("N96");
 
   menu->addMenu("N97");
 
   menu->addMenu("N97");
   but1=new QPushButton("Menu");
+
   but1=new QPushButton("Menu",this);
 
   but1->setMenu(menu);
 
   but1->setMenu(menu);
 
   lay->addWidget(but1);
 
   lay->addWidget(but1);

Revision as of 08:30, 5 August 2009

Article Metadata
Tested with
Devices(s): 5800 Xpress Muzic
Compatibility
Platform(s): S60 3rd Edition, S60 5th Edition
Symbian
Article
Keywords: QPushButton
Created: (27 Jun 2009)
Last edited: savaj (05 Aug 2009)

Contents

Introduction

Program shows the menu generated when button is pressed.

Preconditions

Source Code

Source File

#include "button.h"
#include "ui_button.h"
 
button::button(QWidget *parent)
: QWidget(parent)
{
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);
setLayout(lay);
}
 
button::~button()
{
// No need to delete any object that got a parent that is properly deleted.
}

Screenshot

Butmenu.JPG

Butmenu1.JPG


Related Links

172 page views in the last 30 days.
×