Instantiating the QT object in the NEW method

Moderator: Rathinagiri

Post Reply
User avatar
concentra
Posts: 256
Joined: Fri Nov 26, 2010 11:31 am
Location: Piracicaba - Brasil

Instantiating the QT object in the NEW method

Post by concentra »

Hi.
I moved the instantiation of the associated QT object in window.prg from the CREATE to the NEW method.
I tested all the samples and none of them presented problems or different behavior, so I committed to SVN.
In fact, in the old fashion, samples\statusbar\demo_4.prg didn´t perform correct and in the new one it does. The icons were not associated because the window wasn´t instantiated.
[[]] Mauricio Ventura Faria
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: Instantiating the QT object in the NEW method

Post by l3whmg »

Hi Mauricio, many thanks.
Please, take a look at the end of viewtopic.php?f=5&t=1873&start=40

Cheers
Luigi from Italy
www.L3W.it
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: Instantiating the QT object in the NEW method

Post by l3whmg »

Hi Mauricio,
I look at your code, but I can't compile example. Why? Because I don't have the libHbQtxxxx.a libraries in according with Harbour compiler distribuited with HMG. I have the new (with standard Harbour distribution), but they can't work with HMG because there are some differences; in fact, we are waiting the start (from MrDuck) to do some changes in HMG4 about Qt functions.
For this reason I remember to every one: don't change your Harbour installation with the new version to compile HMG programs.
Now I will do a merge of the current HMG version to a hybrid HMG version.
Cheers
Luigi from Italy
www.L3W.it
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: Instantiating the QT object in the NEW method

Post by l3whmg »

Hi Mauricio, I've done some test, but...
I can not figure out if: I forgot something, I misunderstood something or is there some big problem :shock:

I write this code:

Code: Select all

#include "hmg.ch"

MEMVAR win1

FUNCTION Main

   LOCAL oWindow
   PUBLIC win1

   hbQt_ErrorSys()

   WITH OBJECT oWindow := Window():New()
      :Name       := "win1"
      :Fontname   := "Helvetica"
      :Row        := 10
      :Col        := 10
      :Width      := 400
      :Height     := 400
      :Title      := "Nice OOP Demo!!!"
      :Type       := WND_MAIN
      :OnInit     := { || Main_OnInit() }

   END WITH

   oWindow:Activate()

RETURN NIL

STATIC FUNCTION Main_OnInit()

  win1:Center()

RETURN NIL
This doesn't work: win1:Center() Why?

Cheers
Luigi from Italy
www.L3W.it
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: Instantiating the QT object in the NEW method

Post by l3whmg »

Hi Mauricio, other...but it's the same

Code: Select all

#include "hmg.ch"

MEMVAR win1

FUNCTION Main

   LOCAL oWindow
   PUBLIC win1

   hbQt_ErrorSys()

   WITH OBJECT oWindow := Window():New()
      :Name       := "win1"
      :Fontname   := "Helvetica"
      :Row        := 10
      :Col        := 10
      :Width      := 400
      :Height     := 400
      :Title      := "Nice OOP Demo!!!"
      :Type       := WND_MAIN
      :OnInit     := { || oWindow:Center() }

      WITH OBJECT Label():New()
         :Name     := "label1"
         :Row      := 20
         :Col      := 40
         :Width    := 200
         :Value    := 'OOP LABEL!!!'
      END WITH

      WITH OBJECT Button():New()
         :Name     := "button1"
         :Row      := 160
         :Col      := 40
         :Width    := 180
         :Caption  := "Show FontName"
         :OnClick   := { || Button1_OnClick() }
      END WITH

   END WITH

   oWindow:Activate()

RETURN NIL

STATIC FUNCTION Main_OnInit()

//  win1:Center() It doesn't work

RETURN NIL

STATIC FUNCTION Button1_OnClick()

  MsgInfo( win1:Label1:Caption() , "Label CAPTION" )

RETURN NIL
The last win1:Label1:Caption() it does'nt work

Cheers
Luigi from Italy
www.L3W.it
User avatar
concentra
Posts: 256
Joined: Fri Nov 26, 2010 11:31 am
Location: Piracicaba - Brasil

Re: Instantiating the QT object in the NEW method

Post by concentra »

Hi Luigi !
The window object is oWindow and you are referencing win1...
I see you "named" it win1 but, is this supposed to be valid in HMG ?
[[]] Mauricio Ventura Faria
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: Instantiating the QT object in the NEW method

Post by l3whmg »

Hi Mauricio,
the name it's mandatory for a lot of reason!
1) In this way is very easy to refer to various objects in the program. On the other hand, the name "win1" is the object oWindow but it's named "win1". Of course it's HMGx
2) Within a program, as you can get or set a value of a form or a control of this form? examples:
cVarName1 := oWindow1:oControl1:Value // oWindow1:oControl1:Value := "luigi" and
cVarName2 := oWindow2:oControl1:Value // oWindow2:oControl1:Value := "Mauricio" and...
or you prefer this
cVarName1 := win1:FirstName:Value // win1:FirstName:Value := "Luigi" and
cVarName2 := win2:FirstName:Value // win2:FirstName:Value := "Mauricio" and...
Perhaps, in a complete Object Oriented Program works fine, but not in this situation.

3) Backward compatibility

My suggestion: you must think in standard XBase style but solve with object.

Cheers
Luigi from Italy
www.L3W.it
User avatar
concentra
Posts: 256
Joined: Fri Nov 26, 2010 11:31 am
Location: Piracicaba - Brasil

Re: Instantiating the QT object in the NEW method

Post by concentra »

Hi Luigi.

Don´t know about HMG3, but seems that this never worked in HMG4...
I tested older versions from sourceforge.net and none of them worked.
[[]] Mauricio Ventura Faria
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: Instantiating the QT object in the NEW method

Post by l3whmg »

Ok Mauricio.
perhaps HMG4 has problems? For example take a look at "samples\button\demo_3.prg" and you can see HMG3 style and HMG4 style.

Cheers
Luigi from Italy
www.L3W.it
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: Instantiating the QT object in the NEW method

Post by l3whmg »

Hy guys,
I must say I'm sorry to Mauricio and everyone because I do a mistake :cry:

I give a wrong information about form. This is my mistake:

Code: Select all

 WITH OBJECT oWindow := Window():New()
      :Name       := "win1"
The good one is

Code: Select all

 WITH OBJECT win1 := Window():New()
I'm very sorry.

Best regards
Luigi from Italy
www.L3W.it
Post Reply