×
Namespaces

Variants
Actions

Archived:Como adicionar o ícone em um botão, em Qt

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

Qt Quick should be used for all UI development on mobile devices. The approach described in this article (based on QWidget) is deprecated.

Este trecho de código demonstra como adicionar ícones para os botões em Qt.

Article Metadata

Testado com
Aparelho(s): Emulador

Compatibilidade
Plataforma(s): S60 3ª Edição FP1, S60 3ª Edição FP2, S60 5ª Edição
Symbian

Artigo
Palavras-chave: QIcon, Push Button
Tradução:
Por maiconherverton
Última alteração feita por hamishwillee em 11 Oct 2012

Função Main

  • Método para definir o ícone:
button->setIcon(QIcon("c://butterfly.png"));

Código-fonte

#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();
}

Imagens

Qticon.png

This page was last modified on 11 October 2012, at 04:13.
89 page views in the last 30 days.
×