Results 1 to 8 of 8

Thread: make a widget paint itself even thought it is not shown

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    258
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android
    Thanks
    22
    Thanked 19 Times in 16 Posts

    Default Re: make a widget paint itself even thought it is not shown

    Quote Originally Posted by wysota View Post
    Your problem is that widget is only resized for the first time when it is first shown.
    Well the problem shows up everytime the widget is resized while hidden.

    Quote Originally Posted by wysota View Post
    There are ways to fake visibility of a widget - you need to set some flags for it, grab its contents and clear the flags again. Also calling ensurePolished() and family could be advisable.
    Sounds promising. I'll try that.

    Quote Originally Posted by wysota View Post
    [/code]
    Exactly . Thanks for the interesting links.

    Thanks a lot

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

    Default Re: make a widget paint itself even thought it is not shown

    Quote Originally Posted by momesana View Post
    Well the problem shows up everytime the widget is resized while hidden.
    The question is why would you want to resize a widget when it's hidden... it'd be a pure waste of cpu cycles.

  3. #3
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    258
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android
    Thanks
    22
    Thanked 19 Times in 16 Posts

    Default Re: make a widget paint itself even thought it is not shown

    Quote Originally Posted by wysota View Post
    The question is why would you want to resize a widget when it's hidden... it'd be a pure waste of cpu cycles.
    Well, I don't. All I want is to have grabWidget() take this into consideration before taking the screenshot so it doesn't return outdated pixmaps or pixmaps whose size does not correspond to the actual current size of the widget :-). So I don't question Qt's policy of ignoring (rather postponing ...) such events when the widget is hidden, but the way grabWidget works. It should do whatever is necessary to return a pixmap that resembles the way the widget would look like if it was shown.

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

    Default Re: make a widget paint itself even thought it is not shown

    grabWidget() grabs the widget at its current state. Calling ensurePolished() might help, although it's a long shot. In general I'd try avoiding grabbing an invisible widget, if I were you. Remember that a widget only has a size when it is visible. In all other situations its size should be treated as undetermined. If you want a dirty hack, use this:
    Qt Code:
    1. widget->show();
    2. qApp->processEvents();
    3. QPixmap px = QPixmap::grabWidget(widget);
    4. widget->hide();
    5. qApp->processEvents();
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Drawing a widget in QItemDelegate's paint method
    By darkadept in forum Qt Programming
    Replies: 17
    Last Post: 11th August 2009, 05:15
  2. Compiling with Qmake/Make
    By VireX in forum Newbie
    Replies: 25
    Last Post: 22nd February 2007, 05:57

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
  •  
Qt is a trademark of The Qt Company.