×
Namespaces

Variants
Actions
Revision as of 19:44, 17 September 2009 by nayan_trivedi (Talk | contribs)

Archived:How to add an icon to a QPushButton

From Nokia Developer Wiki
Jump to: navigation, search


{{{width}}}


Article Metadata
Tested with
Devices(s): Emulator
Compatibility
Platform(s): S60 3rd Edition FP1, S60 3rd Edition FP2, S60 5th Edition
Symbian
Article
Keywords: QIcon, Push Button
Created: (09 Jan 2009)
Last edited: nayan_trivedi (17 Sep 2009)


Overview

This code snippet demonstrates how to add icons to buttons in Qt for Symbian.

Preconditions


Main Function

  • Function to set Icon
button->setIcon(QIcon("c://butterfly.png"));

Source File

#include <QApplication>
#include <QPushButton>
#include <QWidget>
#include <QHBoxLayout>
#include <QIcon>
 
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
 
QWidget *win = new QWidget;
QHBoxLayout *layout = new QHBoxLayout;
QPushButton *button = new QPushButton;
 
button->setIcon(QIcon("c://butterfly.png"));
 
QPushButton *button1 = new QPushButton;
button1->setIcon(QIcon("c://savebutton.png"));
QPushButton *button2 = new QPushButton;
button2->setIcon(QIcon("c://exitbutton.png"));
layout->addWidget(button);
layout->addWidget(button1);
layout->addWidget(button2);
 
win->setLayout(layout);
win->showMaximized();
return app.exec();
}

Screenshot

Qticon.png

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

×