I'm experimenting with direct painting to device contexts using WINAPI. Here's what my widget's paintEvent function looks like:

Qt Code:
  1. void ShotView::paintEvent(QPaintEvent *event)
  2. {
  3. qDebug() << "Start paint function";
  4.  
  5. HDC hdc = this->getDC();
  6.  
  7. if (hdc == NULL)
  8. {
  9. qDebug() << "HDC error";
  10. return;
  11. }
  12.  
  13. qDebug() << "Start painting";
  14.  
  15. HPEN hPen = CreatePen(PS_SOLID, 4, RGB(0, 255, 0));
  16. if (hPen == NULL)
  17. qDebug() << "CreatePen error";
  18. if (SelectObject(hdc, hPen) == HGDI_ERROR)
  19. qDebug() << "SelectObject error";
  20. if (MoveToEx(hdc, 0, 0, NULL) == 0)
  21. qDebug() << "MoveToEx error";
  22. if (LineTo(hdc, 200, 200) == 0)
  23. qDebug() << "LineTo error";
  24.  
  25. qDebug() << "End painting";
  26.  
  27. this->releaseDC(hdc);
  28.  
  29. qDebug() << "End paint function";
  30. }
To copy to clipboard, switch view to plain text mode 

When I run the program, I don't see a solid red line appearing as I should. The console output seems correct:

Start paint function
Start painting
End painting
End paint function
so it looks like everything in the function is getting called properly, but I don't see an output. It's been a while since I've done WINAPI stuff, but I think I have it right. Can anyone offer any insight?