×
Namespaces

Variants
Actions
(Difference between revisions)

Archived:Creating Context Menu from QPushButton

From Nokia Developer Wiki
Jump to: navigation, search
jimgilmour1 (Talk | contribs)
m (new version 4.6 download link)
liuxg (Talk | contribs)
Line 41: Line 41:
 
   lay->addWidget(but1);
 
   lay->addWidget(but1);
 
   win->setLayout(lay);
 
   win->setLayout(lay);
   win->win->setStyleSheet("* { background-color:rgb(125,100,50);color:rgb(200,150,100); padding: 7px}}");
+
   win->setStyleSheet("* { background-color:rgb(125,100,50);color:rgb(200,150,100); padding: 7px}}");
 
}
 
}
  

Revision as of 04:40, 4 January 2010

{{{width}}}
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: liuxg (04 Jan 2010)

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.

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

Mybutton001001.jpg


Related Links

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

×