Results 1 to 4 of 4

Thread: Get backgorund as pixmap

  1. #1

    Default Get backgorund as pixmap

    I disabled drawing for dialog backgound and on paintEvent OpenGL renders something on whole background.

    Is it possible to get this "paint" as data pixmap in application then change if and repaing background. if yes how (esp getting background as pixma)? I could not find method in docs to do that.

    Thanks all in advance.

  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: Get backgorund as pixmap

    See QPainter::setRedirected().
    It is better to add a QWidget on the dialog and treat this as "background".

    Then:
    Qt Code:
    1. QPainter::setRedirected(backWidget, &thePixmap);
    To copy to clipboard, switch view to plain text mode 

    Now all painting is done on the pixmap.

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Get backgorund as pixmap

    QWidget::render() (introduced in Qt 4.3) might also be handy..
    J-P Nurmi

  4. #4

    Default Re: Get backgorund as pixmap

    I tryed like that:

    ...
    QRect ur = e->rect();

    QPixmap bgrWidget(ur.width(), ur.height());

    QPainter::setRedirected(this, &bgrWidget);

    //OpenGL renderer draws something here on background

    QImage* m_image = &bgrWidget.toImage();

    ...

    QPainter::restoreRedirected(this);

    QPainter painter(this);

    painter.begin(this);
    painter.drawImage(0,0,*m_image);
    painter.end();

    ....

    1 - OpenGL still draw on background.
    2 - when second draw occurs it's cmpletelly white and everyhting flickers.

    What I'm doing wrong here ?

Similar Threads

  1. cursor pixmap during drag&drop
    By darksaga in forum Qt Programming
    Replies: 1
    Last Post: 14th November 2007, 15:55
  2. Changing QDrag's pixmap
    By Gopala Krishna in forum Qt Programming
    Replies: 2
    Last Post: 13th January 2007, 05:08
  3. Invalid pixmap
    By munna in forum Newbie
    Replies: 2
    Last Post: 8th June 2006, 08:00
  4. Paint XP radio button to pixmap
    By Ben.Hines in forum Qt Programming
    Replies: 2
    Last Post: 26th April 2006, 21:15
  5. Changing pixmap in PixmapLabel
    By bullerwj in forum Qt Tools
    Replies: 1
    Last Post: 11th April 2006, 22:28

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.