Thanks
There is somthing simple I'm missing.
I want to draw a line ( xs, ys, xe, ye ) on a QFrame.
In Qt3 i had
QPainter p( drawings ); /// set drawing pixmap
and
p.drawLine( xs, ys, xe, ye );
In Qt4 with the same code I get A SIGABRT abort message.
I have writen small program to try to work things.out.
I used designer for the layout [IMG]/home/pete/DF-Tutorial/pgn35[/IMG] (hope you get this ).
my header code
#ifndef EDPFORM_H
#define EDPFORM_H
#include <QtGui>
#include <qrect.h>
#include "ui_edpform.h"
{
Q_OBJECT
public:
edpForm();
public slots:
protected:
protected slots:
private:
Ui::edpForm ui;
private slots:
void slotPb1();
void slotPb2();
signals:
void fk1clicked();
void fk2clicked();
};
#endif
#ifndef EDPFORM_H
#define EDPFORM_H
#include <QtGui>
#include <qrect.h>
#include "ui_edpform.h"
class edpForm: public QMainWindow
{
Q_OBJECT
public:
edpForm();
public slots:
protected:
void paintEvent(QPaintEvent *event);
protected slots:
private:
Ui::edpForm ui;
private slots:
void slotPb1();
void slotPb2();
signals:
void fk1clicked();
void fk2clicked();
};
#endif
To copy to clipboard, switch view to plain text mode
and the cpp file
#include "edpform.h"
#include <qpainter.h>
#include <qpixmap.h>
edpForm::edpForm()
{
ui.setupUi(this);
connect( ui.pb3, SIGNAL( clicked() ), this, SLOT( close() ) );
connect( ui.pb1, SIGNAL( clicked() ), this, SLOT( slotPb1() ) );
connect( ui.pb2, SIGNAL( clicked() ), this, SLOT( slotPb2() ) );
ui.input->setFocus();
}
void edpForm::slotPb1()
{
int width = ui.drawingBox->width();
int height = ui.drawingBox->height();
p.drawLine( 0, 0, width, height );
}
void edpForm::slotPb2()
{
ui.input->clear();
}
{
ui.input->setText(" Test" ); /// when displayed show "paintEvent" has been accesed.
}
#include "edpform.h"
#include <qpainter.h>
#include <qpixmap.h>
edpForm::edpForm()
{
ui.setupUi(this);
connect( ui.pb3, SIGNAL( clicked() ), this, SLOT( close() ) );
connect( ui.pb1, SIGNAL( clicked() ), this, SLOT( slotPb1() ) );
connect( ui.pb2, SIGNAL( clicked() ), this, SLOT( slotPb2() ) );
ui.input->setFocus();
}
void edpForm::slotPb1()
{
int width = ui.drawingBox->width();
int height = ui.drawingBox->height();
QPainter p( ui.drawingBox );
p.drawLine( 0, 0, width, height );
}
void edpForm::slotPb2()
{
ui.input->clear();
}
void edpForm::paintEvent(QPaintEvent *event)
{
QPrinter printer;
ui.input->setText(" Test" ); /// when displayed show "paintEvent" has been accesed.
}
To copy to clipboard, switch view to plain text mode
This compiles ok, but when run I get "widget painting begins as a result of paintEvent".
Right now I don't what I'm missing.When I start the program, it goes to the paintEvent because I get the "WoW" is the "input" box.
I know I missing somthing simple, but I'm about brain dead over this.
Thanks for the help.
Bookmarks