Hi,
can anyone suggest any issue,
i want to paint in QWidget with QPaintEvent containing method
but i don't know how to call it in right way, to make it work.
Due to that i use netbeans and my form i create with QTDesigner i placed my method
in form class, but it doesn't work.
there is my code
Field.h
|
Source code
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
#ifndef _FIELD_H
#define _FIELD_H
#include "ui_Field.h"
class Field : public QDialog {
Q_OBJECT
public:
Field();
virtual ~Field();
private:
int currentLevel;
Ui::Field widget;
protected:
void Paint(QPaintEvent* event);
};
#endif
|
Field.cpp
|
Source code
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
#include "Field.h"
Field::Field() {
widget.setupUi(this);
widget.pole->setPalette(QPalette(QColor(170, 255, 0)));
widget.pole->setAutoFillBackground(true);
currentLevel=45;
update();
}
Field::~Field() {}
void Field::Paint(QPaintEvent* )
{
QPainter painter(widget.pole); //widget.pole is that QWidget object where i want to draw
painter.drawText(200,200,tr("Level= ")
+QString::number(currentLevel));
}
|
it would be nice if someone could help me with this.
P.S. sorry for my bad english