Results 1 to 3 of 3

Thread: QPixmap::grabWindow too slow

  1. #1
    Join Date
    Jan 2006
    Posts
    105
    Thanks
    21
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QPixmap::grabWindow too slow

    Hello,

    I have a widget, that makes a screenshot every second and paints it out:
    Qt Code:
    1. ZoomWidget::ZoomWidget(QWidget* parent) : QWidget(parent)
    2. {
    3. QTimer *timer = new QTimer(this);
    4. connect(timer, SIGNAL(timeout()), this, SLOT(update()));
    5. timer->start(1000);
    6. }
    7.  
    8. void ZoomWidget::paintEvent(QPaintEvent * /*event*/) {
    9. QPainter painter(this);
    10. painter.drawPixmap(0, 0, QPixmap::grabWindow(QApplication::desktop()->winId()), 0, 0, 100, 100);
    11.  
    12. }
    To copy to clipboard, switch view to plain text mode 

    it works, but slows down my system quite a lot (every second a small lag)

    if i change the interval to 1ms, X has 100% percent processor-load.

    how could i speed up this?

    (i took a look at kmag - which does basically the same thing in qt3 and is much faster - not really fast either - but still better)

    niko

  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: QPixmap::grabWindow too slow

    Get a snapshot only when you need it. It is very expensive to grab the desktop widget.

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

    niko (31st August 2006)

  4. #3
    Join Date
    Jan 2006
    Posts
    105
    Thanks
    21
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QPixmap::grabWindow too slow

    thanks, that helped a lot!
    (i could have thought about that myselfe...)

    niko

Similar Threads

  1. QTableWidget Update - slow
    By DPinLV in forum Qt Programming
    Replies: 16
    Last Post: 18th August 2006, 21:09
  2. selecting lots of treewidget itemns slow ...
    By jh in forum Qt Programming
    Replies: 15
    Last Post: 19th June 2006, 18:52
  3. QT4 layout of complex dialog is very slow
    By cboles in forum Qt Programming
    Replies: 15
    Last Post: 28th April 2006, 19:57
  4. slow writing on flash disk
    By ir210 in forum KDE Forum
    Replies: 15
    Last Post: 13th February 2006, 15:40
  5. Replies: 1
    Last Post: 20th January 2006, 12:01

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.