Solved QPainter and 2D Graphics
-
Does this code work well? I can not compile it. (Qt 5.7.1)
QPainter and 2D Graphics// error: use of undeclared identifier 'engine'; did you mean 'inline'? if (engine) ^~~~~~ inline
-
@masayoshi From a quick view on that example engine wasn't declared anywhere. You can simply change it like this:
if (engine) painter.begin(engine); else painter.begin(this);
to
painter.begin(this);
Is it possible to download source code for the examples there?
You should ask authors of the book. -
@jsulm said in QPainter and 2D Graphics:
@masayoshi From a quick view on that example engine wasn't declared anywhere. You can simply change it like this:
if (engine) painter.begin(engine); else painter.begin(this);
to
painter.begin(this);
Is it possible to download source code for the examples there?
You should ask authors of the book.After doing that, I can compile it.
When I save image to SVG, I get the following error.//your code here QWidget::paintEngine: Should no longer be called QPainter::begin: Paint device returned engine == 0, type: 1 QPainter::end: Painter not active, aborted
-
@masayoshi
Can you show the code that saves ?
It seems like you are using a QPainter outside the Paint function which is not supported. -
@mrjj said in QPainter and 2D Graphics:
@masayoshi
Can you show the code that saves ?
It seems like you are using a QPainter outside the Paint function which is not supported.Chapter 3. QPainter and 2D Graphics
I only used this code. I used Qt 5.7
-
@jsulm said in QPainter and 2D Graphics:
Is it possible to download source code for the examples there?
You should ask authors of the book.Thank you. I read book carefully. I got source code. It works on my computer.
I will look it up carefully.// Source code if (generator) painter.begin(generator); else painter.begin(this);