martian
29th June 2009, 22:33
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.
BOOL WINAPI DllMain( HINSTANCE hInstance, DWORD dwReason, LPVOID lpvReserved )
{
static bool ownApplication = FALSE;
if ( dwReason == DLL_PROCESS_ATTACH )
ownApplication = QMfcApp::pluginInstance( hInstance );
if ( dwReason == DLL_PROCESS_DETACH && ownApplication )
delete qApp;
return TRUE;
}
extern "C" __declspec(dllexport) bool initGUI( HWND parent )
{
QWinWidget* win = new QWinWidget( parent );
win->setFixedSize(600,200);
win->move(10,10);
QHBoxLayout *hbox = new QHBoxLayout(win);
QLabel *label = new QLabel("QWinWidget -> QLabel");
QLineEdit *edit = new QLineEdit();
hbox->addWidget(label);
hbox->addWidget(edit);
win->show();
return true;
}
initGUI is called from within WinMain of the win32 application which creates a standard black window using CreateWindowEx.
HMODULE mod = LoadLibrary(L"MigrateApplication.dll");
typedef BOOL(*pInitGUI)(HWND parent);
pInitGUI showGUI = (pInitGUI)GetProcAddress( mod, "initGUI" );
if ( showGUI )
showGUI( hWnd );
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.
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.
BOOL WINAPI DllMain( HINSTANCE hInstance, DWORD dwReason, LPVOID lpvReserved )
{
static bool ownApplication = FALSE;
if ( dwReason == DLL_PROCESS_ATTACH )
ownApplication = QMfcApp::pluginInstance( hInstance );
if ( dwReason == DLL_PROCESS_DETACH && ownApplication )
delete qApp;
return TRUE;
}
extern "C" __declspec(dllexport) bool initGUI( HWND parent )
{
QWinWidget* win = new QWinWidget( parent );
win->setFixedSize(600,200);
win->move(10,10);
QHBoxLayout *hbox = new QHBoxLayout(win);
QLabel *label = new QLabel("QWinWidget -> QLabel");
QLineEdit *edit = new QLineEdit();
hbox->addWidget(label);
hbox->addWidget(edit);
win->show();
return true;
}
initGUI is called from within WinMain of the win32 application which creates a standard black window using CreateWindowEx.
HMODULE mod = LoadLibrary(L"MigrateApplication.dll");
typedef BOOL(*pInitGUI)(HWND parent);
pInitGUI showGUI = (pInitGUI)GetProcAddress( mod, "initGUI" );
if ( showGUI )
showGUI( hWnd );
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.