Skip to main content
panduvittala
Inspiring
March 3, 2014
Answered

plugin panel with qt GUI turns white while moving panel on windows

  • March 3, 2014
  • 1 reply
  • 3400 views

The subject says it all. My plugin has a panel rendered by qt (using qwinwidget). When I try to move the panel by dragging using mouse, the qt UI part turns completely white. It goes back to normal when the mouse is released. This  happens only on windows - mac works fine. Has anybody faced this issue? How to fix this? Thanks in advance.

Qt: 485

Illustrator: CC

OS: Windows 7 64 bit

This topic has been closed for replies.
Correct answer A. Patterson

Thank you so much.


You can find the sample here. I built it using the upcoming CC SDK but I think it should be okay for compiling on the older CC. If you need to run this on CS6 you may need to tweak a few things, but I think most of the Empty Panel sample code is the same CS6+.

You'll need to have QTDIR defined before opening Studio for this to work. It also uses an environment variable called ILLUSTRATOR that points to the root of the Illustrator folder, but only for debugging.

http://file-post.net/en/fs5/data/1402427655_2834312253_72/?id=Og6sjxBLISjU

Note that this download expires in 3 days. I built the code and got the white-while-dragging bug. Then I dropped in my windows message proc function and it went away, so that should be a good example of the fix.

1 reply

panduvittala
Inspiring
April 1, 2014

Help please! I am stuck

Known Participant
April 1, 2014

Post the code and any info relevant info for us to understand the big picture before attempting to guess the problem.

Qt and Ai Plugin solution is very complicated, we all faced many problems and if you don't describle visually and accurately it is hard to help you solve it.

panduvittala
Inspiring
June 9, 2014

Ah, crap. Sorry, I just realized what part of the problem is. I was lifting code from a utility class we use to manage the DC stuff and internally it called CreateDC(), but it only took a reference to an HDC. I thought that was the Windows API, but it was actually a private method that does a little more.

Replace CreateDC(dc); in my original post with this:

__CreateDC(dc);

and add this function:

void CreateDC(HDC& outDC)

{

     HDC screenDC = 0;

     HDC memoryDC = 0;

     GetDC(0, screenDC);

     memoryDC = CreateCompatibleDC(screenDC);

     ReleaseDC(0, screenDC);

     outDC = memoryDC;
}

Again, obviously that lacks any error checking, but hopefully it works fine


Nope, didn't work. Here is the latest code.

Interestingly, if I pass screenDC to bitblt instead of hdc from hwnd, it paints the bitmap at top left corner of screen. It just does not work on the panel window. Looks like qt painting is overwriting even the bitblt drawing.

      case WM_PRINT:

           {

   if(!panelWidget)
   break;
   QPixmap widgetPixmap = QPixmap::grabWidget(panelWidget);
   widgetPixmap.save("c:\\temp\\test.bmp");
   HBITMAP bitmap = widgetPixmap.toWinHBITMAP();

   HDC hdc=GetDC(hWnd);//reinterpret_cast<HDC>(wParam);

   HDC memdc = 0;
   HGDIOBJ oldObject = 0;
   //dc=CreateDC(TEXT("DISPLAY"), 0, 0, 0);

   HDC screenDC = GetDC(0);
   memdc = CreateCompatibleDC(screenDC);
   ReleaseDC(0, screenDC);

   oldObject=SelectObject(memdc, bitmap);
  
   DIBSECTION dibSection;
   GetObject(bitmap, sizeof(dibSection), &dibSection);
   BitBlt(hdc, 0, 0, dibSection.dsBmih.biWidth, dibSection.dsBmih.biHeight, memdc, 0, 0, SRCCOPY);

   if (oldObject) {
   SelectObject(memdc, oldObject);
   }

   DeleteDC(memdc);
   DeleteObject(bitmap);
           }

           break;