QLabel & Win32 native handle
-
I to all,
I need the win32 native handle of a QT Widget, particullary of the
QLabel widget; I've writed the following code:
@
QLabel* qLab = diag.findChild<QLabel*>("label"); // diag is the parent window of QLabel (QTDialog)
QWindow* w = qLab->windowHandle();
HWND h = static_cast<HWND>(inter->nativeResourceForWindow(QByteArrayLiteral("handle"), w);
@
the problem is that w pointer return a ZERO value and, conseguently, h is set to 0 :(Best Regards
Leonard[Edit: Please be sure to wrap code in @ tags -- mlong]
-
Hi and welcome to devnet,
Isn't "winId":http://qt-project.org/doc/qt-5/qwindow.html#winId what you are looking for ?
-
Hi, thanks to reply !
I want use the following acad/Objectarx function:acdbDisplayPreviewFromDwg(ACHAR*, void*, Adesk::UInt32*)
to display a dwg thumbnail on a dialog; with MFC it works if I set the
second parameter to the HWND of a 'Picture Control' or 'Text Control'.
But I love QT :) and I want use QWinWidget and QTDialog ...Your suggest doesn't works:
b = acdbDisplayPreviewFromDwg(result->resval.rstring, (HWND)qLab->winId(), &bCol);
:(
Best Regards
Leonard[quote author="SGaist" date="1395676216"]Hi and welcome to devnet,
Isn't "winId":http://qt-project.org/doc/qt-5/qwindow.html#winId what you are looking for ? [/quote]
-
Did you check that winId returns a valid value ?
-
Another thing that you can try is setting Qt::WA_NativeWindow on your widget before calling winId
-
Hi :(,
does'nt works ... the code now is:QLabel* qLab = diag.findChild<QLabel*>("label");
qLab->setAttribute(Qt::WA_NativeWindow);
HWND h = (HWND)qLab->winId();
Adesk::UInt32 bCol = RGB(255,0,255);
b = acdbDisplayPreviewFromDwg(result->resval.rstring, h, &bCol);With MFC the working code is:
acdbDisplayPreviewFromDwg(wstrFName, m_pStaticWnd->m_hWnd, &bCol)
where 'm_pStaticWnd->m_hWnd' returns an HWND value, and m_pStaticWnd is a 'CWnd*' pointer to the ‘Text Control’ widget ...
Why the QLabel widget doesn't show the bitmap ? Can be a painting
refresh problem ?Best regards
Leonard[quote author="SGaist" date="1395788591"]Another thing that you can try is setting Qt::WA_NativeWindow on your widget before calling winId[/quote]
-
That I can't say but it might be.
By the way, why do you need to call acdbDisplayPreviewFromDwg ?
-
I just saw "this":http://qt-project.org/doc/qt-5/qwidget.html#effectiveWinId that might also be of some help
-
I developing an autocad plugin (OBjectArx dll),
and I use the acdbDisplayPreviewFromDwg() function to display
a preview of a dwg file (little thumbnail)There is a QT function to read dwg file ?
Thanks in advance
[quote author="SGaist" date="1395869296"]I just saw "this":http://qt-project.org/doc/qt-5/qwidget.html#effectiveWinId that might also be of some help[/quote]
-
Not to read DWG file. However, if there's a DWG library than is usable somewhere there's always the option of writing a QImageIOPlugin using it.