Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    QLabel & Win32 native handle

    General and Desktop
    2
    11
    3565
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • L
      leonimas last edited by

      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]

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi and welcome to devnet,

        Isn't "winId":http://qt-project.org/doc/qt-5/qwindow.html#winId what you are looking for ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 0
        • L
          leonimas last edited by

          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]

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            Did you check that winId returns a valid value ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply Reply Quote 0
            • L
              leonimas last edited by

              [quote author="SGaist" date="1395697547"]Did you check that winId returns a valid value ?[/quote]

              Yes I've checked, winId returns a not null value: 0x000605c0

              Best Regards
              Leonard

              1 Reply Last reply Reply Quote 0
              • SGaist
                SGaist Lifetime Qt Champion last edited by

                Another thing that you can try is setting Qt::WA_NativeWindow on your widget before calling winId

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply Reply Quote 0
                • L
                  leonimas last edited by

                  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]

                  1 Reply Last reply Reply Quote 0
                  • SGaist
                    SGaist Lifetime Qt Champion last edited by

                    That I can't say but it might be.

                    By the way, why do you need to call acdbDisplayPreviewFromDwg ?

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply Reply Quote 0
                    • SGaist
                      SGaist Lifetime Qt Champion last edited by

                      I just saw "this":http://qt-project.org/doc/qt-5/qwidget.html#effectiveWinId that might also be of some help

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply Reply Quote 0
                      • L
                        leonimas last edited by

                        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]

                        1 Reply Last reply Reply Quote 0
                        • SGaist
                          SGaist Lifetime Qt Champion last edited by

                          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.

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post