Results 1 to 6 of 6

Thread: Using StretchDIBits() in QWidget

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2006
    Posts
    19
    Thanks
    12

    Default Using StretchDIBits() in QWidget

    Hi

    I've subclasses a QWidget because I want to perform my own drawing using Windows' StretchDIBits() function (I'm painting video frames). I've overwritten QWidget::paintEvent() where I'm doing my drawing like this:

    Qt Code:
    1. void MyWidget::paintEvent(QPaintEvent *p)
    2. {
    3. HWND hWnd = winId();
    4. HDC hdc;
    5. PAINTSTRUCT ps;
    6. hdc = BeginPaint(hWnd, &ps);
    7. BOOL b = StretchDIBits(hdc, 0, 0, rect().width(), rect().height(), 0, 0,
    8. bmh.biWidth, bmh.biHeight*-1, frm->frame, &bmi,
    9. DIB_RGB_COLORS, SRCCOPY);
    10. EndPaint(hWnd, &ps);
    11. }
    To copy to clipboard, switch view to plain text mode 

    'bmh' is a BITMAPINFOHEADER and 'frm' is a byte-array of bitmap data.

    When the paintEvent is called nothing is, however, shown. Why is this? When I use the above code in my MFC app it works fine (when I receive WM_PAINT).

    -- Bjoern
    Last edited by wysota; 4th May 2009 at 19:20. Reason: missing [code] tags

Similar Threads

  1. QtScript Binding problem with QWidget
    By zack in forum Qt Programming
    Replies: 3
    Last Post: 17th February 2009, 09:38
  2. Replies: 0
    Last Post: 11th November 2008, 15:36
  3. Dynamic updates of a QWidget in a QScrollArea
    By plamkata in forum Qt Programming
    Replies: 2
    Last Post: 20th July 2008, 23:45
  4. Error in put one QWidget in another QWidget
    By xjtu in forum Qt Programming
    Replies: 1
    Last Post: 19th April 2008, 16:05
  5. Replies: 3
    Last Post: 8th March 2007, 14:54

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.