Results 1 to 3 of 3

Thread: Newbie -- repaint() not repainting window

  1. #1
    Join Date
    Mar 2015
    Posts
    1
    Qt products
    Qt5
    Platforms
    MacOS X

    Smile Newbie -- repaint() not repainting window

    I'm not sure if this is a bug in Qt 5.4.1 or I'm doing something wrong. Here is my stripped down code that is failing to repaint the window EXCEPT when I call resize() after a repaint(). If you run the code below, it'll properly repaint the window. If you remove the last call to resize() at the bottom, it will NOT repaint the window. Any help is appreciated. Thanks.

    QPlainTextEdit mytextbox;

    mytextbox.resize(500,500);
    mytextbox.insertPlainText("first string");
    mytextbox.show();
    mytextbox.insertPlainText("DID IT CHANGE??");
    sleep(1);
    mytextbox.repaint();
    mytextbox.resize(500,501);

  2. #2
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: Newbie -- repaint() not repainting window

    Where are you executing this code? Since you are not returning to the event loop between calls to insertPlainText, I'm not surprised that you are forced to manually repaint or resize (which also requires a paint).

    What happens if you replace sleep(1) with processEvents()?

  3. #3
    Join Date
    Nov 2014
    Location
    Chennai
    Posts
    160
    Thanks
    65
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Newbie -- repaint() not repainting window

    try this line in your program
    activateWindow();
    bt am not this was correct its just my suggestion
    Quote Originally Posted by a7scenario View Post
    I'm not sure if this is a bug in Qt 5.4.1 or I'm doing something wrong. Here is my stripped down code that is failing to repaint the window EXCEPT when I call resize() after a repaint(). If you run the code below, it'll properly repaint the window. If you remove the last call to resize() at the bottom, it will NOT repaint the window. Any help is appreciated. Thanks.

    QPlainTextEdit mytextbox;

    mytextbox.resize(500,500);
    mytextbox.insertPlainText("first string");
    mytextbox.show();
    mytextbox.insertPlainText("DID IT CHANGE??");
    sleep(1);
    mytextbox.repaint();
    mytextbox.resize(500,501);

Similar Threads

  1. [qt5] repainting qwidget
    By zodiac in forum Qt Programming
    Replies: 11
    Last Post: 25th July 2012, 15:10
  2. Replies: 4
    Last Post: 17th October 2010, 22:30
  3. Replies: 2
    Last Post: 29th June 2010, 00:40
  4. QGraphicsItem not repainting
    By eijnuhs in forum Qt Programming
    Replies: 3
    Last Post: 20th September 2008, 08:54
  5. Repainting widget
    By fear in forum Qt Programming
    Replies: 3
    Last Post: 26th March 2008, 08:37

Tags for this Thread

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.