Results 1 to 3 of 3

Thread: paintEvent - execute four times

  1. #1
    Join Date
    May 2017
    Posts
    13
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default paintEvent - execute four times

    Hello,
    I have some strange problem.
    I have empty project, just clicked "New QT Widget Application", and after I execute that code:

    Qt Code:
    1. void MainWindow::paintEvent(QPaintEvent *e)
    2. {
    3. cout << 1 << endl;
    4. }
    To copy to clipboard, switch view to plain text mode 

    I get result like:
    1
    1
    1
    1

    So it looks like paintEvent function is repeated 4 times automaticaly. Why does it work like that? Can't I change it in some way to just one execution?

    For any help thanks in advance.
    Best Regards

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: paintEvent - execute four times

    It might be caused by the way your desktop works.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Nov 2016
    Location
    Ridgecrest California
    Posts
    33
    Thanks
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Windows Android

    Default Re: paintEvent - execute four times

    It might be helpful if you post more or all of your code. I attempted to re-create your situation and after a bit of juggling I was able to reproduce part of the problem. It displayed two lines of 1's (not 4).

Similar Threads

  1. Nested loop only loops 3 times instead of 710 times
    By ayanda83 in forum Qt Programming
    Replies: 1
    Last Post: 18th October 2016, 18:12
  2. QResizeEvent called 3 times
    By mvbhavsar in forum Newbie
    Replies: 5
    Last Post: 17th December 2014, 16:06
  3. How to use a class multiple times?
    By xtlc in forum Newbie
    Replies: 5
    Last Post: 8th August 2013, 15:48
  4. Print a QWebView many times
    By Eddyc in forum Qt Programming
    Replies: 0
    Last Post: 28th August 2012, 10:37
  5. Qwt 6.0.1 three times slower than 5.2.0
    By Spitfire in forum Qwt
    Replies: 13
    Last Post: 26th September 2011, 10:05

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.