Namespaces
Variants
Actions

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

Jump to: navigation, search
Archived.png
Archived: 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.

Dados do artigo

Testado com
Aparelho(s): Emulador

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

Artigo
Palavras-chave: QIcon, Push Button
Tradução:
Ú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.
165 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved