Setting the label as a child of the button seems like a good way to do it . The button still works as expected and has its appearance defined by the label.
#include <QApplication>
#include <QPushButton>
#include <QLabel>
int main(int argc, char *argv[])
{
QLabel *label
= new QLabel("<h2><i>Hello</i> ""<font color=red>Qt!</font></h2>",button
);
QObject::connect(button,
SIGNAL(clicked
()),
&a,
SLOT(quit
()));
button->show();
button->setWindowTitle("HelloWorld Test Program");
label->setAlignment(Qt::AlignCenter|Qt::AlignVCenter);
label->show();
return a.exec();
}
#include <QApplication>
#include <QPushButton>
#include <QLabel>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QPushButton *button = new QPushButton(NULL);
QLabel *label = new QLabel("<h2><i>Hello</i> ""<font color=red>Qt!</font></h2>",button);
QObject::connect(button, SIGNAL(clicked()), &a, SLOT(quit()));
button->show();
button->setWindowTitle("HelloWorld Test Program");
label->setAlignment(Qt::AlignCenter|Qt::AlignVCenter);
label->show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks