PDA

View Full Version : How to draw something anywhere on screen?



teromin
28th November 2010, 16:24
Here's the part of code from "C++-GUI-Programming-with-QT-4":


#include <QWidget>
#include <QApplication>
#include <QPainter>
class myWidget : public QWidget {
Q_OBJECT
public:
myWidget(QWidget *parent=0);
void paintEvent(QPaintEvent *event)
}
void MyWidget::paintEvent(QPaintEvent *event) {
QPainter painter(this);
painter.drawEllipse(80, 80, 400, 240);

}
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
myImage image;
???
}



So, I want to draw an ellipse.
How to do it with QPaintEvent?
The best decision for me would be, if it would draw ellipse right after program started, but connection QDrawEvent and for example QPushButton event clicked() would be useful for me :)



Thank you.

tbscope
28th November 2010, 16:46
You have the book, start with chapter 1