2

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

demonplus
  • 5,613
  • 12
  • 49
  • 68

1 Answers1

3

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 *)
Jeremy Friesner
  • 70,199
  • 15
  • 131
  • 234