Results 1 to 4 of 4

Thread: QPixmap::grabWindow does not work on some machines!

  1. #1
    Join Date
    Jul 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default QPixmap::grabWindow does not work on some machines!

    Hello,
    please help to solve, QPixmap::grabWindow does work on some XP machines and does not
    work on the others,meaning i get empty bytes array


    void screenshoot(QByteArray *p_bar)
    {
    QBuffer a_Buf;
    QPixmap originalPixmap;
    originalPixmap = QPixmap::grabWindow(QApplication::desktop()->winId());
    originalPixmap.save(&a_Buf, "jpg");
    *p_bar = a_Buf.buffer();
    }

    Qt4, MSVW 2008, WinXP, project compiled in release

    thanks in advance,
    dima

  2. #2
    Join Date
    Aug 2008
    Posts
    134
    Thanks
    10
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QPixmap::grabWindow does not work on some machines!

    open the a_Buf using
    Qt Code:
    1. a_Buf.open(QIODevice::WriteOnly);
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. QPixmap pixmap;
    2. QByteArray bytes;
    3. QBuffer buffer(&bytes);
    4. buffer.open(QIODevice::WriteOnly);
    5. pixmap.save(&buffer, "PNG"); // writes pixmap into bytes in PNG format
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jul 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QPixmap::grabWindow does not work on some machines!

    thank you navi

    it is almost works.
    If i use bmp format it works on that (specific) computer,
    but if u use Jpeg
    QBuffer a_Buf;
    a_Buf.open(QIODevice::WriteOnly);
    QPixmap lPixmap;
    Pixmap = QPixmap::grabWindow(QApplication::desktop()->screen()->winId());
    lPixmap.save(QApplication::applicationDirPath() + "\\screenshoot.jpeg", "jpeg");

    there is no jpeg file produced as well as the gif

    thanks in advance,
    dima

  4. #4
    Join Date
    Jul 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QPixmap::grabWindow does not work on some machines!

    i have found the problem,
    it was plugins not setup on target machine.
    looks like jpeg implemented in Qt as plugin.

Similar Threads

  1. Replies: 1
    Last Post: 23rd February 2012, 11:13
  2. QPixmap is null on other machines
    By sepehr in forum Installation and Deployment
    Replies: 6
    Last Post: 12th July 2011, 07:24
  3. QPixmap::grabWindow() problem
    By mtroscheck in forum Qt Programming
    Replies: 1
    Last Post: 7th February 2009, 00:15
  4. Replies: 1
    Last Post: 21st August 2008, 07:44
  5. QPixmap::grabWindow too slow
    By niko in forum Newbie
    Replies: 2
    Last Post: 31st August 2006, 06:40

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.