I want to draw ellipse in UI but my code doesn't work.
QWidget::paintEngine: Should no longer be called QPainter::begin: Paint device returned engine == 0, type: 1
Mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow), pm(100,100)
{
ui->setupUi(this);
//set_form_style();
draw_ellipse();
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::set_form_style(){
//setWindowFlags(Qt::FramelessWindowHint);
//setAttribute(Qt::WA_TranslucentBackground);
//ui->widget->setStyleSheet("background:transparent;");
setMouseTracking(true);
}
void MainWindow::draw_ellipse(){
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
painter.setBrush(QBrush(Qt::red, Qt::SolidPattern));
painter.drawEllipse(100, 50, 150, 150);
}