×
Namespaces

Variants
Actions
(Difference between revisions)

Archived:Creating Context Menu from QPushButton

From Nokia Developer Wiki
Jump to: navigation, search
savaj (Talk | contribs)
(added QPushButton to object trees to cleanup properly.)
mind_freak (Talk | contribs)
(screenshot changed)
Line 2: Line 2:
 
|id=...
 
|id=...
 
|platform=S60 3rd Edition, S60 5th Edition
 
|platform=S60 3rd Edition, S60 5th Edition
|devices=5800 Xpress Muzic
+
|devices=Emulator
 
|category=Qt for S60
 
|category=Qt for S60
 
|subcategory= UI
 
|subcategory= UI
Line 12: Line 12:
  
 
==Introduction==
 
==Introduction==
Program shows the menu generated when button is pressed.
+
Program shows the menu generated when button is pressed.Here the QMenu is implemented in the pushbutton.
  
 
==Preconditions==
 
==Preconditions==
Line 29: Line 29:
 
     : QWidget(parent)
 
     : QWidget(parent)
 
{
 
{
 +
  win=new QWidget(this);
 +
  win->resize(400,500);
 
   lay=new QHBoxLayout(this);
 
   lay=new QHBoxLayout(this);
 
   menu=new QMenu(this);
 
   menu=new QMenu(this);
Line 37: Line 39:
 
   but1->setMenu(menu);
 
   but1->setMenu(menu);
 
   lay->addWidget(but1);
 
   lay->addWidget(but1);
   setLayout(lay);
+
   win->setLayout(lay);
 +
  win->win->setStyleSheet("* { background-color:rgb(125,100,50);color:rgb(200,150,100); padding: 7px}}");
 
}
 
}
  
Line 47: Line 50:
  
 
==Screenshot==
 
==Screenshot==
[[Image:Butmenu.JPG]]
 
  
[[Image:Butmenu1.JPG]]
+
[[Image:Mybutton001001.jpg]]
  
  
 
==Related Links==
 
==Related Links==
 
* [[How_to_use_QPushButton_(Qt_for_S60)|How to use QPushButton]]
 
* [[How_to_use_QPushButton_(Qt_for_S60)|How to use QPushButton]]

Revision as of 09:14, 11 August 2009

Article Metadata
Tested with
Devices(s): Emulator
Compatibility
Platform(s): S60 3rd Edition, S60 5th Edition
Symbian
Article
Keywords: QPushButton
Created: (27 Jun 2009)
Last edited: mind_freak (11 Aug 2009)

Contents

Introduction

Program shows the menu generated when button is pressed.Here the QMenu is implemented in the pushbutton.

Preconditions

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->win->setStyleSheet("* { background-color:rgb(125,100,50);color:rgb(200,150,100); padding: 7px}}");
}
 
button::~button()
{
// No need to delete any object that got a parent that is properly deleted.
}

Screenshot

Mybutton001001.jpg


Related Links

265 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.

×