Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

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

From 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 01:13.
460 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.

×