Results 1 to 8 of 8

Thread: How to "flush" display?

  1. #1
    Join Date
    Mar 2006
    Posts
    142
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default How to "flush" display?

    Hello,
    I have a class inherited from QAbstractItemView in which the mouseReleaseEvent() method have been overloaded so as to perform selection of items. The selection works well and the paintEvent() method is supposed to highlight them. It works well, ie the right items are selected, but I need to cover part of the widget and them show it again for paintEvent() to be executed. I tried almost everything I could think about as a solution, which leads now:
    Qt Code:
    1. this->update();
    2. QCoreApplication::processEvents();
    To copy to clipboard, switch view to plain text mode 
    but paintEvent() is still not synchronously called.
    So how to cope with this issue?

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to "flush" display?

    update just schedules a paint event, it does not trigger an immediate update.
    I don't fully understand your problem... Maybe you can elaborate a bit.

  3. #3
    Join Date
    Mar 2006
    Posts
    142
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to "flush" display?

    Quote Originally Posted by marcel View Post
    update just schedules a paint event, it does not trigger an immediate update.
    I don't fully understand your problem... Maybe you can elaborate a bit.
    Of course. I just would like to force an immediate execution of paintEvent(), I mean I would like that the paintEvent() be effective immediatement after update().

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to "flush" display?

    Quote Originally Posted by Caius Aérobus View Post
    I just would like to force an immediate execution of paintEvent(), I mean I would like that the paintEvent() be effective immediatement after update().
    You can use QWidget::repaint() instead.

  5. #5
    Join Date
    Mar 2006
    Posts
    142
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to "flush" display?

    Quote Originally Posted by jacek View Post
    You can use QWidget::repaint() instead.
    I did it... but it does not change anything!

  6. #6
    Join Date
    Mar 2006
    Location
    Mountain View, California
    Posts
    489
    Thanks
    3
    Thanked 74 Times in 54 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to "flush" display?

    repaint() does not work on all platforms. You can only paint to a widget (including to an item in a scene rendered by a QGraphicsView widget) during a paint event.

    I don't understand your original problem though. Why would you want to paint an item immediately after painting it? The user would not be able to see the first paint because it would happen so fast. Why not just paint the item once? In your mouseReleaseEvent() you can set an appropriate state on the item and call update(). Then in paintEvent() drw the item according to the state you set.

  7. #7
    Join Date
    Mar 2006
    Posts
    142
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to "flush" display?

    Quote Originally Posted by Brandybuck View Post
    repaint() does not work on all platforms. You can only paint to a widget (including to an item in a scene rendered by a QGraphicsView widget) during a paint event.

    I don't understand your original problem though. Why would you want to paint an item immediately after painting it? The user would not be able to see the first paint because it would happen so fast. Why not just paint the item once? In your mouseReleaseEvent() you can set an appropriate state on the item and call update(). Then in paintEvent() drw the item according to the state you set.
    That's what I did but the paintEvent() is not processed until I put a window on top of my application window and show it again.

  8. #8
    Join Date
    Mar 2006
    Posts
    142
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to "flush" display?

    I have fixed the problem: it is a Mac issue because the same code compiled on Linux works well.

Similar Threads

  1. Replies: 12
    Last Post: 7th September 2011, 16:37
  2. Replies: 8
    Last Post: 18th March 2011, 11:27
  3. OS/X how to get physical display handle
    By hvengel in forum Qt Programming
    Replies: 4
    Last Post: 3rd January 2009, 19:51
  4. Display only PNG image on desktop
    By durbrak in forum Qt Programming
    Replies: 32
    Last Post: 15th March 2008, 21:55
  5. Graphics view display problem.
    By kiranraj in forum Qt Programming
    Replies: 3
    Last Post: 20th July 2007, 07:08

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.