Page 1 of 2 12 LastLast
Results 1 to 20 of 24

Thread: How to sendEvent QPaintEvent ?

  1. #1
    Join Date
    Apr 2008
    Location
    Russia, Moscow
    Posts
    86
    Thanks
    2
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4

    Question How to sendEvent QPaintEvent ?

    I want redraw one widget without hi's childs, how to use QProcess::sendEvent with QPaintEvent ? I try this, but this doesn't work:

    Qt Code:
    1. QPaintEvent *pe = new QPaintEvent(ui->groupBox->rect());
    2. ui->groupBox->setAttribute(Qt::WA_WState_InPaintEvent, true);
    3. QApplication::sendEvent(ui->groupBox, pe);
    4. ui->groupBox->setAttribute(Qt::WA_WState_InPaintEvent, false);
    To copy to clipboard, switch view to plain text mode 

    But this code work and i dont' undrestand why:

    Qt Code:
    1. QPaintEvent *pe = new QPaintEvent(ui->groupBox->rect());
    2. QPixmap pix(ui->groupBox->size());
    3. pix.fill(Qt::white);
    4. QPainter::setRedirected(ui->groupBox, &pix);
    5. QApplication::sendEvent(centralWidget(), pe);
    6. QPainter::restoreRedirected(ui->groupBox);
    7. pix.save("file.jpg");
    To copy to clipboard, switch view to plain text mode 

  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: How to sendEvent QPaintEvent ?

    What's wrong with calling repaint() or update? The children should be taken from the backing store if they didn't change and their background didn't change.
    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
    Apr 2008
    Location
    Russia, Moscow
    Posts
    86
    Thanks
    2
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4

    Default Re: How to sendEvent QPaintEvent ?

    Quote Originally Posted by wysota View Post
    What's wrong with calling repaint() or update? The children should be taken from the backing store if they didn't change and their background didn't change.
    I want prevent childrens repaint for overpainting from parent widget. I want change order for repaint recursion. Parent must be last.

  4. #4
    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: How to sendEvent QPaintEvent ?

    But this will make it paint over the children so you would see nothing. If you really want that have an overlay widget that is transparent and uses QWidget::render() to retrieve a pixmap of the parent and use drawPixmap to paint it on itself.
    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.


  5. #5
    Join Date
    Apr 2008
    Location
    Russia, Moscow
    Posts
    86
    Thanks
    2
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4

    Default Re: How to sendEvent QPaintEvent ?

    We found other solution.


    installEventFilter for all childs, QApplication::sendEvent in QEvent::Paint for each child.

  6. #6
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to sendEvent QPaintEvent ?

    From the above pic, how do u expect to work with the combo box ?
    Also the hip hop screen looks more like a splash screen

  7. #7
    Join Date
    Apr 2008
    Location
    Russia, Moscow
    Posts
    86
    Thanks
    2
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4

    Default Re: How to sendEvent QPaintEvent ?

    Quote Originally Posted by aamer4yu View Post
    From the above pic, how do u expect to work with the combo box ?
    Also the hip hop screen looks more like a splash screen
    Combobox and etc will be over picture, this is true. But i thing this not really matter

    Also the hip hop screen looks more like a splash screen
    Only "looks like", this overpaint for each child.

  8. #8
    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: How to sendEvent QPaintEvent ?

    Using an overlay this would have been much simpler and quicker in terms of performance

    [wiki]Widget Overlay[/wiki]
    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.


  9. #9
    Join Date
    Apr 2008
    Location
    Russia, Moscow
    Posts
    86
    Thanks
    2
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4

    Default Re: How to sendEvent QPaintEvent ?

    Quote Originally Posted by wysota View Post
    Using an overlay this would have been much simpler and quicker in terms of performance

    [wiki]Widget Overlay[/wiki]
    I read this page before, but for academic interest i want use only paint features, without any additional widgets. And, unfortunately, i found some things that Qt can't do.
    It would be very nice if the QtSoftware will make an additional functionality for such things.

  10. #10
    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: How to sendEvent QPaintEvent ?

    Quote Originally Posted by SABROG View Post
    And, unfortunately, i found some things that Qt can't do.
    Ok, such as?
    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.


  11. #11
    Join Date
    Apr 2008
    Location
    Russia, Moscow
    Posts
    86
    Thanks
    2
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4

    Default Re: How to sendEvent QPaintEvent ?

    Quote Originally Posted by wysota View Post
    Ok, such as?
    Like painting over widgets without additional widget and hemorroid with installEventFilter and reimplement paintEvent for all childs. Like create semi-transparent main widget with system titlebar or just titlebar paint from Qt (semi-transparent widget without flag Qt::FramelessWindowHint).

    ---
    More experiments...
    Last edited by SABROG; 28th May 2009 at 09:22.

  12. #12
    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: How to sendEvent QPaintEvent ?

    Quote Originally Posted by SABROG View Post
    Like painting over widgets without additional widget and hemorroid with installEventFilter and reimplement paintEvent for all childs.
    I'm sure you'll admit this is not what normally people do :-)

    By the way, look here: http://www.qtcentre.org/forum/showth...ht=post+filter

    Like create semi-transparent main widget with system titlebar or just titlebar paint from Qt (semi-transparent widget without flag Qt::FramelessWindowHint).
    And here: Creating Translucent Windows. For the title bar blame your system - it is not part of the application so it has no control over it.

    Any other requests? :-)
    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.


  13. The following user says thank you to wysota for this useful post:

    SABROG (28th May 2009)

  14. #13
    Join Date
    Apr 2008
    Location
    Russia, Moscow
    Posts
    86
    Thanks
    2
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4

    Default Re: How to sendEvent QPaintEvent ?

    Quote Originally Posted by wysota View Post
    I'm sure you'll admit this is not what normally people do :-)

    By the way, look here: http://www.qtcentre.org/forum/showth...ht=post+filter
    Thanks for link, this what we actually doing, but with call QApplication::sendEvent again.

    Quote Originally Posted by wysota View Post
    And here: Creating Translucent Windows. For the title bar blame your system - it is not part of the application so it has no control over it.

    Any other requests? :-)
    With system titelbar i understand. Qt cat draw titlebar from code in QGraphicsWidget for QGraphicsScene. But simple users can't call this painter for Translucent Windows and must write own implementation for this.

    --Updated--
    I post our solution on wiki.crossplatform.ru
    Last edited by SABROG; 28th May 2009 at 12:39.

  15. #14
    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: How to sendEvent QPaintEvent ?

    Quote Originally Posted by SABROG View Post
    But simple users can't call this painter for Translucent Windows and must write own implementation for this.
    I don't understand what you mean.
    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.


  16. #15
    Join Date
    Apr 2008
    Location
    Russia, Moscow
    Posts
    86
    Thanks
    2
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4

    Default Re: How to sendEvent QPaintEvent ?

    I try explain. This widget is translucene without system titlebar. What you see - QStyleOptionTitleBar and style()->drawComplexControl(QStyle::CC_TitleBar, &o, &painter, this); (about 115 lines in paintEvent + 138 lines in events like mousePressEvent etc)



    Why Qt can't draw titlebars for widget outside QGraphicsScene if she can?

  17. #16
    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: How to sendEvent QPaintEvent ?

    Because the window manager does that. If Qt draws something, it also has to handle it. You don't have things such as system menus or taskbar entries for the windows embedded into Graphics Scene, do you? If you want, you can draw the title bar yourself using QStyle. But it will only look like a title bar, not be one.
    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.


  18. #17
    Join Date
    Apr 2008
    Location
    Russia, Moscow
    Posts
    86
    Thanks
    2
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4

    Default Re: How to sendEvent QPaintEvent ?

    What i want - just titlebar functionality on translucent widgets. Maybe without system menu etc, but with move widget by mouse and working buttons. Like QMdiSubWindow, but as how MainWindow
    Last edited by SABROG; 28th May 2009 at 14:04.

  19. #18
    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: How to sendEvent QPaintEvent ?

    [wiki]Moving widgets[/wiki]
    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.


  20. #19
    Join Date
    Apr 2008
    Location
    Russia, Moscow
    Posts
    86
    Thanks
    2
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4

    Default Re: How to sendEvent QPaintEvent ?

    You don't understand me. I write all code myself and he's work. But this huge work and i don't understand why i must do this work if Qt can draw QMdiSubWindow and QGraphicsWidget with titlebar (not system) with full functionality. But Qt don't provide features for creating like this widgets as Main Window, who created how translucene and can't have titlebars.

  21. #20
    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: How to sendEvent QPaintEvent ?

    Because if it did, you would immediately have asked why the title bar behaved differently that ones from native applications. Qt is not an ultimate solution for everything, it's an application framework. You have the tool - QStyle - use it for non-standard cases and don't expect Trolls to solve all of your problems. If they did, it would be fair if you gave them all the money you earn by writing software. I don't think that is really what you want.
    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.


Similar Threads

  1. QPaintEvent syntax question
    By last2kn0 in forum Newbie
    Replies: 5
    Last Post: 25th January 2008, 20:36
  2. QPaintEvent on button click?
    By vishal.chauhan in forum Qt Programming
    Replies: 1
    Last Post: 5th June 2007, 08:44
  3. Replies: 4
    Last Post: 26th July 2006, 07:06
  4. Inheritance and QpaintEvent
    By djoul in forum Qt Programming
    Replies: 22
    Last Post: 5th July 2006, 13:56

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.