Get the QMainWindow() handle

54 views
Skip to first unread message

Bernard Mouille

unread,
Feb 12, 2024, 3:22:47 PMFeb 12
to QtContribs
Hello,
To get the QMainWindow() handle, I use :

hHandle := wapi_FindWindow( nil, oWnd:windowTitle )

Is exists a property or a method to get directly the QMainWindow() handle ?

Using :
Harbour version  : Harbour 3.2.0dev (r2307062207)
GCC version      : MinGW GNU C 7.3 (32-bit)
QT version       : 4.7.2

Thanks,
Bernard.

Luigi Ferraris

unread,
Feb 13, 2024, 6:55:17 AMFeb 13
to qtcon...@googlegroups.com
Hi Bernard,
AFAIK the only two methods via HbQt are
<object>:effectiveWinId() or <object>:winId()
I don't know about
<object>:windowHandle()

In any case, read carefully Qt documentation about value returned and other info.
From my pov, it could be dangerous (I don't know your final usage) and arduous. Qt seems to discourage their use.
 
Regards
Luigi


Bernard Mouille

unread,
Feb 13, 2024, 10:00:14 AMFeb 13
to QtContribs
Hello Luigi,
Thanks for your post.
I have try and not works in my qt version 4.7.2 :

   oWnd := QMainWindow()
//   ? oWnd:effectiveWinId() // Error.
//   ? oWnd:winId() // Error.
//   ? oWnd:windowHandle() // Error.

//   ? effectiveWinId( oWnd ) // No hb_func.
//   ? winId( oWnd ) // No hb_func.
//   ? windowHandle( oWnd ) // No hb_func.

//   ? GetFormHandle( oWnd ) // ( HMG ) No hb_func.

Regards,
Bernard.

Luigi Ferraris

unread,
Feb 13, 2024, 1:58:59 PMFeb 13
to qtcon...@googlegroups.com

Il 13/02/2024 16:00, Bernard Mouille ha scritto:
> Hello Luigi,
> Thanks for your post.
> I have try and not works in my qt version 4.7.2 :

>    oWnd := QMainWindow()
> //   ? oWnd:effectiveWinId() // Error.
> //   ? oWnd:winId() // Error.
> //   ? oWnd:windowHandle() // Error.
this is the right way to call, but (without error text I can't say
anything) you can't print because are pointers.

Anyway, you are using an old Qt version, I don't know if they existed on
version < 4.8. For sure ::windowHandle available from Qt5.0
So, I suggest to upgrade Qt (minimum 5.2) at 5.7

Regards
Luigi

Bernard Mouille

unread,
Feb 13, 2024, 3:09:53 PMFeb 13
to QtContribs
Hello Luigi,

Since 1985, I code in DOS and Novell and after in Windows with :
dbaseIII, Clipper, https://www.dbase.com/ and Harbour ( version 3.0.0 in first).
I have copied the hbqt files from hb30 to hb32 and it works good for me.
I am not able to install the new Qt version : it is not easy like hb30.

Regards,
Bernard.

Luigi Ferraris

unread,
Feb 14, 2024, 6:38:57 AMFeb 14
to QtContribs
Hello Bernard,
I'm not a guru anyway I will try to help you based on my experience; so, be careful and evaluate my suggestions carefully.

I'm assuming on Windows (64 or 32) to build 32bit executable.

The main "problem" is to keep aligned Harbour (and HbQt) with Qt, from C compiler/linker pov.

So, in my opinion the best is:
   a) upgrade your GCC at least able to handle C++11 dialect
      About this I hope there is someone can give you a good solution because I have little knowledge. I'm using MSYS with difficult.
   b) donwload Qt from https://download.qt.io/new_archive/qt/5.7/5.7.0/
      this installer  qt-opensource-windows-x86-mingw530-5.7.0.exe
   c) download Harbour sources (see .zip)
   d) download HbQt

I follow these steps for a main reason: I can check step by step each compilation error.
warning: I'm focusing on Harbour, HbQt and Qt settings requirement.

   1) install Qt somewhere; normally, I try to keep the Qt directory not too far away from the Harbour directory

   2) build Harbour from sources with these MANDATORY settings in your .bat
   SET HB_WITH_QT=%QTINC% where QTINC is your Qt include directory
      e.g. .....\Qt\Qt5.7.0\5.7\mingw53_32\include
   SET HB_QTPATH=%QTBIN% where QTBIN is your Qt bin directory
      e.g. .....\Qt\Qt5.7.0\5.7\mingw53_32\bin
   SET HB_QT_MAJOR_VER=5 most important

   3) expand HbQt within your Harbour/addons directory and build HbQt with these MANDATORY settings in your .bat
   SET HB_WITH_QT=%QTINC% see above
   SET HB_QTPATH=%QTBIN% see above
   SET HB_QT_MAJOR_VER=5 see above
   SET HB_QT_MINOR_VER=7
   SET HB_USER_CFLAGS=-std=gnu++11
   SET QTCONTRIBS_REBUILD=yes

   4) build your program using HbQt with these MANDATORY settings in your .bat
   SET HB_WITH_QT=%QTINC% see above
   SET HB_QTPATH=%QTBIN% see above
   SET HB_QT_MAJOR_VER=5 see above
   SET HB_QT_MINOR_VER=7 see above
   
Obviously, you can keep your current "folders" and create a new one structure on your HD. I think is better!

I hope this can help you.
Regards, Luigi

Bernard Mouille

unread,
Feb 14, 2024, 6:45:24 AMFeb 14
to QtContribs
Hello Luigi,

Thanks for your post.
I am a dummy.

Please, can you post the links for :
- GCC at least able to handle C++11 dialect,
- Harbour sources (see .zip),
- HbQt ?
   
Regards,
Bernard.

Luigi Ferraris

unread,
Feb 14, 2024, 10:02:45 AMFeb 14
to QtContribs
About GCC You can use MSYS2 at https://www.msys2.org/
   Warning: read carefully because I haven't good knowledge.  On Harbour user forum (I believe) you can find more help
  You can install both 32bit & 64bit version into the same folder (I think is good) but You must use 32bit due to Qt libraries
   
About Harbour https://github.com/harbour/core
   click on green button "Code" to get .zip

About HbQt (iow QtContribs) https://sourceforge.net/p/qtcontribs/code/HEAD/tree/
   and click on "Download snapshot" to get .zip

Regards, Luigi

Bernard Mouille

unread,
Feb 14, 2024, 2:13:21 PMFeb 14
to QtContribs
Thanks Luigi.


Reply all
Reply to author
Forward
0 new messages