Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QPainter not working on Android
Qt 6.12 LTS is out! See what's new in the release blog

QPainter not working on Android

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
3 Posts 3 Posters 1.1k Views 1 Watching
  • 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.
  • E Offline
    E Offline
    EMC3
    wrote on last edited by
    #1

    Hello,

    I needed to write a little and simple test app. Wrote the 200 line app and tested on Windows and everything is fine. I compiled it for android and noticed that it ignores completly my QPainter calls. Code:

    void MainWindow::paintEvent(QPaintEvent *event)
    {
        qDebug() << "Paint, imp "<<imagePos;
        QPainter p(this);
        if(imagePos != currentImage.width())p.drawImage(0,0,currentImage,imagePos,0,currentImage.width()-imagePos);
        if(imagePos != 0)p.drawImage(currentImage.width()-imagePos,0,currentImage,0,0,imagePos);
        p.end();
    }
    

    the Output is written on the Console, but the widget is not drawn. Works flawless on Windows...

    Any help?

    Also tried setting autoFillBackground but nothing

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      What are the values of imagePos ? currentImage ? Where does currentImage come from ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mvuori
        wrote on last edited by
        #3

        I guess your MainWindow is derived from QMainWindow...

        AFAIK this may be expected behaviour, though the behaviour depends on the platform and possibly other things. QMainWindow is not supposed to be painted on directly. You should paint on a child widget.

        ...By googling about it you should have noticed that you are not among the first to ask about this...

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