Course. Its very simple.
class ButtonLabel
: public QLabel{
Q_OBJECT
public:
Q_SIGNALS:
void clicked();
};
class ButtonLabel: public QLabel
{
Q_OBJECT
public:
ButtonLabel(QPixmap &pic);
Q_SIGNALS:
void clicked();
};
To copy to clipboard, switch view to plain text mode
ButtonLabel
::ButtonLabel(QPixmap &pic
){
setPixmap(pic);
}
ButtonLabel::ButtonLabel(QPixmap &pic)
{
setPixmap(pic);
}
To copy to clipboard, switch view to plain text mode
int main(int argc, char *argv[])
{
ButtonLabel label(pix);
label.connect(label, SIGNAL(clicked()), label, SLOT(close()));
label.show();
return app.exec();
}
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QPixmap pix(":/button.jpg");
ButtonLabel label(pix);
label.connect(label, SIGNAL(clicked()), label, SLOT(close()));
label.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Edit: Ah, oops, I cut out the connect line... putting it back in, in the third code box
Bookmarks