Results 1 to 5 of 5

Thread: Neither QWidget update() nor repaint() will repaint; only resizing does

  1. #1
    Join Date
    Oct 2010
    Location
    http://www.voom.net
    Posts
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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.

  2. #2
    Join Date
    Oct 2010
    Location
    http://www.voom.net
    Posts
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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.

  3. #3
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default 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.
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  4. #4
    Join Date
    Oct 2010
    Location
    http://www.voom.net
    Posts
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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:
    Qt Code:
    1. #include <QApplication>
    2.  
    3. #include "window.h"
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. Q_INIT_RESOURCE(basicdrawing);
    8. QApplication app(argc, argv);
    9. Window window;
    10. window.show();
    11. return app.exec();
    12. }
    To copy to clipboard, switch view to plain text mode 
    Attached Images Attached Images
    Attached Files Attached Files

  5. #5
    Join Date
    Oct 2010
    Location
    http://www.voom.net
    Posts
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Neither QWidget update() nor repaint() will repaint; only resizing does

    Quote Originally Posted by John Mcgehee View Post
    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.

  6. The following user says thank you to John Mcgehee for this useful post:

    ComServant (10th January 2015)

Similar Threads

  1. Replies: 4
    Last Post: 10th June 2010, 21:25
  2. x11,about qwidget::repaint()
    By calmspeaker in forum Qt Programming
    Replies: 7
    Last Post: 9th December 2009, 06:50
  3. Replies: 5
    Last Post: 18th April 2007, 10:29
  4. Use of repaint/update
    By Placido Currò in forum Qt Programming
    Replies: 3
    Last Post: 3rd April 2007, 19:24
  5. Replies: 1
    Last Post: 13th July 2006, 21:10

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.