Android Qt - custom button does not appear

  • 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");

    MyButton::paintEvent(QPaintEvent *)
    QPainter p;
    The button does not show... Where do I have problem?

  • 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.

  • Yea, I think so...

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.