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. Qt android paintevent problem?
Qt 6.11 is out! See what's new in the release blog

Qt android paintevent problem?

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
3 Posts 3 Posters 1.3k 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.
  • K Offline
    K Offline
    kkkkxxxx
    wrote on last edited by
    #1

    #include "mainwindow.h"
    #include "ui_mainwindow.h"

    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);
    }

    MainWindow::~MainWindow()
    {
    delete ui;
    }

    void MainWindow::paintEvent(QPaintEvent *event)
    {
    QPainter painter(this);
    painter.setPen(QPen(Qt::red,4));
    painter.drawLine(QPoint(10,10),QPoint(100,400)); //drawLine() Without any effect, without any display?
    painter.setBrush(Qt::yellow);
    painter.drawRect(100,100,100,100);//drawRect() Without any effect, without any display?
    }

    //On the QT Android 6 system。
    //drawLine(),drawRect() Without any effect, without any display?
    //How to use painter()??

    raven-worxR 1 Reply Last reply
    0
    • M Offline
      M Offline
      mvuori
      wrote on last edited by
      #2

      Usually, you are not supposed to draw on QMainWindow directly. You should only draw on elements placed on the window.

      Also, when you claim that a function call does not have any effect, check first that it gets executed - It may well be that your paintEvent doesn't get called, lacking a reason to update it... (there should be an update() call generated somewhere).

      1 Reply Last reply
      0
      • K kkkkxxxx

        #include "mainwindow.h"
        #include "ui_mainwindow.h"

        MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
        {
        ui->setupUi(this);
        }

        MainWindow::~MainWindow()
        {
        delete ui;
        }

        void MainWindow::paintEvent(QPaintEvent *event)
        {
        QPainter painter(this);
        painter.setPen(QPen(Qt::red,4));
        painter.drawLine(QPoint(10,10),QPoint(100,400)); //drawLine() Without any effect, without any display?
        painter.setBrush(Qt::yellow);
        painter.drawRect(100,100,100,100);//drawRect() Without any effect, without any display?
        }

        //On the QT Android 6 system。
        //drawLine(),drawRect() Without any effect, without any display?
        //How to use painter()??

        raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by
        #3

        @kkkkxxxx
        as @mvuori said, don't draw on the main window directly. There is a placed widget over your paintings so you wont see them.
        What are you exactly trying to achieve?

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        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