Reputation: 21
I'm trying to drawing a simple line using a dialog but when I compile my code nothing happens, I have the dialog without nothing, please any body could explain me what is happening? Below my code:
#include "dialog.h"
#include "ui_dialog.h"
#include <QPainter>
Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{
ui->setupUi(this);
}
Dialog::~Dialog()
{
delete ui;
}
void Dialog::paintEvent(QPainter *)
{
QPainter painter(this);
painter.drawLine(10,10,100,100);
}
I don't know what is wrong
Upvotes: 2
Views: 513
Reputation: 73081
This line is wrong:
void Dialog::paintEvent(QPainter *)
It has the wrong arguments-signature, so it is not getting called. It should instead be:
void Dialog::paintEvent(QPaintEvent *)
Upvotes: 3