Android Qt - custom button does not appear
-
wrote on 22 Sept 2012, 21:19 last edited by
Hi guys, I wanted to create a custom styled button which would have an image on background but when I run the project, nothing appears - image is loaded, but the painting does not show:
@
MyButton::MyButton(QWidget *parent)
: QPushButton(parent)
{
setFixedSize(45, 45);
pixmap = new QPixmap(45,45);
qDebug() << pixmap->load(":/interface/Back.png");
}
@@
void
MyButton::paintEvent(QPaintEvent *)
{
QPainter p;
p.begin(this);
p.setBrush(Qt::SolidPattern);
p.setBackground(QBrush(pixmap->toImage()));
p.end();
}
@
The button does not show... Where do I have problem? -
wrote on 24 Sept 2012, 10:10 last edited by
You are not doing any actual painting, it seems. I think you misunderstand what QPainter::setBackground does. My feeling is, that you are looking for QPainter::drawPixmap instead.
-
wrote on 24 Sept 2012, 14:44 last edited by
Yea, I think so...
1/3