Welcome to the Project Developers' Table

Moderator: Rathinagiri

User avatar
Rathinagiri
Posts: 5482
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Welcome to the Project Developers' Table

Post by Rathinagiri »

mrduck wrote:Last message for today, I promise :-)

see this code:

Code: Select all

METHOD OnClick( bValue ) CLASS CONTROL

   IF ::lCreated
      IF Pcount() == 0
         RETURN ::bOnClick
      ELSEIF Pcount() == 1
         ::bOnClick := bValue
         *::oQTObject:DisConnect( "clicked()" )
         ::oQTObject:Connect( "clicked()" , ::bOnClick )
      ENDIF
   ELSE
      IF pcount() == 0
         RETURN ::bOnClick
      ELSEIF pcount() == 1
         ::bOnClick := bValue
      ENDIF
   ENDIF

   RETURN NIL
I propose some changes (code not tested, it's just a proposal)

Code: Select all

METHOD OnClick( bValue ) CLASS CONTROL

      // one code for  both ::lCreated values
      IF Pcount() > 1
         // error
         ::bOnClick := NIL
      ELSEIF Pcount() == 1
         IF HB_isBlock( bValue )  // check parameter type to avoid chaos
             ::bOnClick := bValue
         ELSE
             // Generate error and/or
             ::bOnClick := NIL   // must remove old codeblock
             return NIL
          ENDIF

         IF ::lCreated .and. hb_isblock( ::bOnClick )
            // force disconnect, ignore return value
            ::oQTObject:DisConnect( "clicked()" )
            // connect
            if ! ::oQTObject:Connect( "clicked()" , ::bOnClick ) 
                // generate error (some errors already generated by :connect,
                // if it returns .F. after a :disconnect there may be other problems...
                ::bOnClick := NIL
         ENDIF  //::lCreated
      ENDIF
 
   RETURN ::bOnClick
A bit of code refactoring, a bit of parameter checking, a bit of error reporting.... just an idea....
Yes. This would be really make HMG working in a bug free environment. Thanks man. We can change all the signals and events like this.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
Rathinagiri
Posts: 5482
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Welcome to the Project Developers' Table

Post by Rathinagiri »

Hi Francesco,

source/widget.prg is not available in svn. Kindly commit that too.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
mrduck
Posts: 497
Joined: Fri Sep 10, 2010 5:22 pm

Re: Welcome to the Project Developers' Table

Post by mrduck »

rathinagiri wrote:
Perhaps we should think about adding [dis]connect methods to class CONTROL
Yes, that is a nice idea. However, some signals/events are widget specific and on change of one widget is different from on change of another widget.
Yes, but instead of calling

oLabel:oQTObject:connect(....)

we will call directly
oLabel:connect(....)

In this way we may "centralize" all connect/disconnect and:
- check that QT objects has been created
- if needed, store the situation
mrduck
Posts: 497
Joined: Fri Sep 10, 2010 5:22 pm

Re: Welcome to the Project Developers' Table

Post by mrduck »

rathinagiri wrote:Hi Francesco,

source/widget.prg is not available in svn. Kindly commit that too.
Sorry sorry sorry....

I can't access svn from work, so can you please commit this code ?

Code: Select all

#include "hbclass.ch"
#include "common.ch"
#include "hbqtgui.ch"
#include "hmg.ch"

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

CLASS WIDGET FROM CONTROL

   DATA cClass     INIT       "WIDGET"
   DATA oCentral   INIT       NIL
   // Methods
   METHOD Create
   METHOD CentralWidgetOf   SETGET
PROTECTED:
   METHOD setCentralWidget

ENDCLASS

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

METHOD setCentralWidget( oWindow ) CLASS WIDGET
  IF ::lCreated
        oWindow:oQTObject:setCentralWidget( ::oQTObject )
        RETURN .T.
  ENDIF

  RETURN .F.



METHOD CentralWidgetOf( oValue ) CLASS WIDGET
Local o

   IF Pcount() == 0
      RETURN ::oCentral
   ELSEIF Pcount() == 1 .AND. valtype( ::oCentral ) == "U"
      ::oCentral := oValue
      // Protection: we can't reassign multiple Widget to Central Widget
      // retrieve current central Widget
      o := oValue:oQTObject:centralWidget()
      // if returned pointer is not valid (means there is no central widget already set)
      //     and widget is created
      IF ! o:hasvalidPointer() .AND. ::lCreated
         ::setCentralWidget( oValue )
         RETURN .T.
      ENDIF
   ENDIF

   RETURN .F.


METHOD Create() CLASS WIDGET

   // Create QT Object and other initialization tasks
   IF valtype( ::oContainer ) == 'U'
      ::oQTObject := QWidget( ::oParent:oQTObject )
   ELSE
      ::oQTObject := QWidget( ::oContainer:oQTObject )
   ENDIF
   ::oParent:AddData( ::cName , Self )

   ::oFont := QFont()

   // Setting '::lCreated' flag, so, runtime properties can be invoked
   ::lCreated := .T.

   IF ValType( ::oCentral )           != 'U'; Self:CentralWidgetoF   := ::oCentral           ; ENDIF

   // Set Properties And Events

   ::oQTObject:show()

   RETURN Self

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

User avatar
Rathinagiri
Posts: 5482
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Welcome to the Project Developers' Table

Post by Rathinagiri »

Ok Francesco. Thanks. I will update.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
Rathinagiri
Posts: 5482
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Welcome to the Project Developers' Table

Post by Rathinagiri »

Uploaded and verified.

It is really nice Francesco.

I wish to know the following:

1. What would be the width and height of the central widget?
2. Will that in direct relationship with the window width and height?
3. Will it change because of adding/removing toolbar(s)?
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
Carlos Britos
Posts: 245
Joined: Sat Aug 02, 2008 5:03 pm

Re: Welcome to the Project Developers' Table

Post by Carlos Britos »

rathinagiri wrote:Uploaded and verified.

It is really nice Francesco.

I wish to know the following:

1. What would be the width and height of the central widget?
2. Will that in direct relationship with the window width and height?
3. Will it change because of adding/removing toolbar(s)?
Hi Francesco, Rathinagiri
Testing the demo3b.prg I have an object (size 100 x 30) over the toolbar buttons and they don't work ok,
I put this to the code at line 62 and seems to work.
::oQTObject:resize( 0, 0 )
::oQTObject:move( 0,0 )
Can you check this please ? Thanks.
Regards/Saludos, Carlos (bcd12a)
mrduck
Posts: 497
Joined: Fri Sep 10, 2010 5:22 pm

Re: Welcome to the Project Developers' Table

Post by mrduck »

rathinagiri wrote: I wish to know the following:

1. What would be the width and height of the central widget?
2. Will that in direct relationship with the window width and height?
3. Will it change because of adding/removing toolbar(s)?
1 & 2 & 3: yes

Open Qt Assistant and search "QMainWindow"
mrduck
Posts: 497
Joined: Fri Sep 10, 2010 5:22 pm

Re: Welcome to the Project Developers' Table

Post by mrduck »

Carlos Britos wrote: Hi Francesco, Rathinagiri
Testing the demo3b.prg I have an object (size 100 x 30) over the toolbar buttons and they don't work ok,
I put this to the code at line 62 and seems to work.
::oQTObject:resize( 0, 0 )
::oQTObject:move( 0,0 )
Can you check this please ? Thanks.
Sorry Carlos, I don't understand....to test demo3b you must click on one of the buttons before moving the toolbar.

at line 62 you move resize and move L2...
User avatar
mimmo-italia
Posts: 8
Joined: Thu Oct 21, 2010 6:13 pm
Location: Italia - Foggia

Re: Welcome to the Project Developers' Table

Post by mimmo-italia »

hello,
how can I define a length of characters in a texbox?
Thanks
Post Reply