Results 1 to 8 of 8

Thread: Transparency with QWinWidget

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2009
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    2

    Question Transparency with QWinWidget

    Hi,

    I'm trying to make a QWinWidget transparent over the underlying win32 app, so that I can use Qt's QGraphicsView and all the other great UI classes within my application without blocking the underlying apps controls and graphics.

    So heres some example code of what I'm trying to do:

    Here I have my dll with all the Qt code that I need.

    Qt Code:
    1. BOOL WINAPI DllMain( HINSTANCE hInstance, DWORD dwReason, LPVOID lpvReserved )
    2. {
    3. static bool ownApplication = FALSE;
    4.  
    5. if ( dwReason == DLL_PROCESS_ATTACH )
    6. ownApplication = QMfcApp::pluginInstance( hInstance );
    7. if ( dwReason == DLL_PROCESS_DETACH && ownApplication )
    8. delete qApp;
    9.  
    10. return TRUE;
    11. }
    12.  
    13.  
    14. extern "C" __declspec(dllexport) bool initGUI( HWND parent )
    15. {
    16. QWinWidget* win = new QWinWidget( parent );
    17. win->setFixedSize(600,200);
    18. win->move(10,10);
    19.  
    20. QHBoxLayout *hbox = new QHBoxLayout(win);
    21.  
    22. QLabel *label = new QLabel("QWinWidget -> QLabel");
    23. QLineEdit *edit = new QLineEdit();
    24.  
    25. hbox->addWidget(label);
    26. hbox->addWidget(edit);
    27.  
    28. win->show();
    29.  
    30. return true;
    31. }
    To copy to clipboard, switch view to plain text mode 

    initGUI is called from within WinMain of the win32 application which creates a standard black window using CreateWindowEx.

    Qt Code:
    1. HMODULE mod = LoadLibrary(L"MigrateApplication.dll");
    2.  
    3. typedef BOOL(*pInitGUI)(HWND parent);
    4. pInitGUI showGUI = (pInitGUI)GetProcAddress( mod, "initGUI" );
    5. if ( showGUI )
    6. showGUI( hWnd );
    To copy to clipboard, switch view to plain text mode 

    Now if you look at the attached picture, you will see the QWinWidget's beige background covers the black background of the application. I would like it so that for the Qt Widgets only the QLabel and QLineEdit are viewable and the QWinWidget's background is transparent.

    I know Qt::WA_TranslucentBackground can be used for this type of thing, but that requires a frameless window and I need the widget's embedded in the main window.

    I may be crazy but I'm looking for any and all possible ways to achieve this, thanks for reading and for any help!

    This is for Qt 4.5+, Windows. I have attached the sample applications source.
    Attached Images Attached Images
    Attached Files Attached Files

Similar Threads

  1. Tree selection - icon transparency (lack of)
    By MrGarbage in forum Qt Programming
    Replies: 1
    Last Post: 8th January 2008, 21:48
  2. Transparency ... Again
    By EricF in forum Qt Programming
    Replies: 4
    Last Post: 1st December 2007, 19:52
  3. Speed, transparency, and drop issues with QGraphicsView
    By jefferai in forum Qt Programming
    Replies: 16
    Last Post: 30th June 2007, 16:14
  4. [QT3+XP] transparency and mouse tracking
    By incapacitant in forum Newbie
    Replies: 9
    Last Post: 17th February 2006, 18:49
  5. transparency
    By roms18 in forum Qt Programming
    Replies: 2
    Last Post: 16th February 2006, 19:38

Tags for this Thread

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.