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.mrduck wrote:Last message for today, I promise
see this code:I propose some changes (code not tested, it's just a proposal)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
A bit of code refactoring, a bit of parameter checking, a bit of error reporting.... just an idea....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
Welcome to the Project Developers' Table
Moderator: Rathinagiri
- 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
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
- 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
Hi Francesco,
source/widget.prg is not available in svn. Kindly commit that too.
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.
South or North HMG is worth.
...the possibilities are endless.
Re: Welcome to the Project Developers' Table
Yes, but instead of callingrathinagiri wrote: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.Perhaps we should think about adding [dis]connect methods to class CONTROL
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
Re: Welcome to the Project Developers' Table
Sorry sorry sorry....rathinagiri wrote:Hi Francesco,
source/widget.prg is not available in svn. Kindly commit that too.
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
/*----------------------------------------------------------------------*/
- 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
Ok Francesco. Thanks. I will update.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
- 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
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)?
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.
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
Hi Francesco, Rathinagirirathinagiri 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)?
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)
Re: Welcome to the Project Developers' Table
1 & 2 & 3: yesrathinagiri 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)?
Open Qt Assistant and search "QMainWindow"
Re: Welcome to the Project Developers' Table
Sorry Carlos, I don't understand....to test demo3b you must click on one of the buttons before moving the toolbar.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.
at line 62 you move resize and move L2...
- mimmo-italia
- Posts: 8
- Joined: Thu Oct 21, 2010 6:13 pm
- Location: Italia - Foggia
Re: Welcome to the Project Developers' Table
hello,
how can I define a length of characters in a texbox?
Thanks
how can I define a length of characters in a texbox?
Thanks