Important: Please read the Qt Code of Conduct -

Qt android paintevent problem?

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

    MainWindow::MainWindow(QWidget *parent) :
    ui(new Ui::MainWindow)

    delete ui;

    void MainWindow::paintEvent(QPaintEvent *event)
    QPainter painter(this);
    painter.drawLine(QPoint(10,10),QPoint(100,400)); //drawLine() Without any effect, without any display?
    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()??

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

  • Moderators

    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?

Log in to reply