Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Android Qt - custom button does not appear
QtWS25 Last Chance

Android Qt - custom button does not appear

Scheduled Pinned Locked Moved Mobile and Embedded
3 Posts 2 Posters 1.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Peppy
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • P Offline
        P Offline
        Peppy
        wrote on last edited by
        #3

        Yea, I think so...

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved