Neither QWidget update() nor repaint() will repaint; only resizing does
I modified the basicdrawing example to create my own program that is very similar. It merely draws text in the RenderArea widget instead of polygons, etc.
When my application starts up, paintEvent() runs and everything looks good. When I change something (like the text string), I do update(), but nothing is repainted. Same thing with repaint(). Just to make sure, I did setUpdatesEnabled(true) immediately before update(). It still does not work.
If instead I resize by moving the corner of the window with the mouse, paintEvent() runs, and everything looks just as I expected, with the updated text string painted. Currently, resizing the window is the only way I can repaint.
I am using Fedora 11 Linux with Qt 4.6.2. I see people recommending Qt 4.6.3, but I hesitate because I compiled basicdrawing with 4.6.2, and it does update() just fine.
Re: Neither QWidget update() nor repaint() will repaint; only resizing does
Fedora 12 has Qt 4.6.3, so I tried linking to 4.6.3, and it did not solve the problem.
Re: Neither QWidget update() nor repaint() will repaint; only resizing does
Can you show us what did you change exactly in this basicdrawing code? Because if it was working before changes and now it isn't so the most possible situation is that ou have done something wrong and we don't know what you have exactly done.
5 Attachment(s)
Re: Neither QWidget update() nor repaint() will repaint; only resizing does
Thank you for your response.
The relevant code is attached. Attachment 5330
This program stores and retrieves the text in an "OA" database, which is not mine to share. A text object in this database has the same attributes as a text you draw with QPainter (origin, orientation, alignment, bounding box, etc.).
vview.jpg shows you the dialog that is created. QPainter is drawing correctly. As I said above, the problem is that I can only get it to redraw by resizing the window
I could only attach five files, so here is the interesting part of main.cpp:
Code:
#include <QApplication>
#include "window.h"
int main(int argc, char *argv[])
{
Q_INIT_RESOURCE(basicdrawing);
Window window;
window.show();
return app.exec();
}
Re: Neither QWidget update() nor repaint() will repaint; only resizing does
Quote:
Originally Posted by
John Mcgehee
When I change something (like the text string), I do update(), but nothing is repainted. Same thing with repaint().
I found the problem. I unintentionally reimplemented QWidget::setVisible(). I just changed the name of my method to setTextVisible(), and now it update() works fine.