Page 2 of 2

Re: Protected oQtObject

Posted: Fri Sep 23, 2011 3:17 pm
by mrduck
concentra wrote:In hmg4 there is layout and widget classes and there is the setCentralWidget method (centralwidgetof). So you should not need to use oQtObject.
As I said, to set the central widget in HMG4 an extra control must be added.
And in my opinion this should be implemented in basic or control in order to permit any control be the central widget without the need to add this extra layer.[/quote]

Can't remember nor check now. Can you create a small example ?

Re: Protected oQtObject

Posted: Fri Sep 23, 2011 4:15 pm
by concentra
mrduck wrote:Can't remember nor check now. Can you create a small example ?
Since only Windows have central widgets, I coded a setget method in window.prg :

Code: Select all

/*----------------------------------------------------------------------*/

METHOD CentralWidget( oValue ) CLASS WINDOW

   IF PCOUNT() == 0
      RETURN ::oCentralWidget
   ELSEIF ! HB_ISNIL( ::oCentralWidget )
      MSGINFO( "Invalid operation. Window already have a central widget." )
   ELSEIF HB_ISOBJECT( oValue )
      ::oQTObject:setCentralWidget( oValue:QtObject() )
      ::oCentralWidget := oValue
   ENDIF

   RETURN NIL

/*----------------------------------------------------------------------*/
Worked as expected.
I put a error message indicating that this can be done only one time in a window...

Re: Protected oQtObject

Posted: Fri Sep 23, 2011 4:28 pm
by mrduck
Ok.

Thanks.

It's similar to the code in WIDGET.prg.... anyway your code is ok if you want to fill the central widget with just ONE widget... if you need to create a layout you have to encapsulate the layout in a widget...

Well, actually we use a method on WIDGET CentralWidgetOf, reversing the action (from the widget to the window) while in Qt (and in your code) is the contrary... it may good anyway...

Re: Protected oQtObject

Posted: Wed Oct 26, 2011 10:37 pm
by l3whmg
Hi friends.
Today I worked upon bitmap object to implement some ideas.
To explore these ideas I have updated my "experiment" and HMG4 with the same code, but the results are different.

In a form I have defined a bitmap (but is like label) with this code

Code: Select all

      WITH OBJECT Bitmap():New( "image1" )
         :Row     := 10
         :Col     := 10
         :Width   := 780
         :Height  := 585
         :Picture := ':FANTASY'
         :BackColor := { 0 , 255 , 0 }
      END WITH
The differences.

Fig.1 with Hmg4 library. This is wrong because there isn't the green background color between menu and image.
This problem is caused by the lack of this code "::oQTObject:setAutoFillBackground( .T. )" within label.prg. If I activate the line, you will see the green color.
hmg4 lib no fill background
hmg4 lib no fill background
Hmg4-NoFillBack.jpg (15.81 KiB) Viewed 3216 times

Fig.2 with Hmg4 library. As you can see there is the green color but.... the label covers the menu. Yes, it's wrong.
hmg4 with fill backgrond
hmg4 with fill backgrond
Hmg4.jpg (13.75 KiB) Viewed 3216 times
Fig.3 with my "experiment".
l3w experiment
l3w experiment
Lqt.jpg (16.48 KiB) Viewed 3216 times
As you can see there aren't problems and the source code into the program it's the same. Why? Where is the difference.
I think because I'm using centralwidget. Always, by default, I define the central widget for every form and every (not always) object has its parent with the central widget.

I think we must use the centralwidget as MrDuck writes.

Best regards.