Other studies on layout

Moderator: Rathinagiri

Post Reply
mrduck
Posts: 497
Joined: Fri Sep 10, 2010 5:22 pm

Other studies on layout

Post by mrduck »

QFormLayout() samples... run the demo and resize the form... can you do this with hmg-3 ?

there is only one drawback, the fact that you need PRIVATE variables, since we need to access objects from the ON INIT function....

Code: Select all


/*

 HMG 4 DEMO
 (c) 2010 Roberto Lopez <mail.box.hmg@gmail.com>

*/

#include "../../include/hmg.ch"
#include "hbqtgui.ch"

Function Main
    qL := NIL
    qW := NIL
    o1 := NIL
    o2 := NIL

	Define Window oWindow				;
		At 20 , 10				;
		Width	1000				;
		Height	550				;
		Title	'QFormLayout test'		;
		Main					;
		On Init { || proviamo(oWindow) } 
	
        qW := Widget():New()	

        With Object o1 := textbox():New()
            :Parent := qW
            :Value    := 'this is a textbox'
        End With

        With Object o2 := DatePicker():New()
            :Parent := qW
        End With
                
        With Object o3 := CheckBox():New()
            :Parent := qW
            :Value    := .F.
        End With
                
        With Object o4 := EditBox():New()
            :Parent := qW
            :Value    := "this is a long text, in a editbox"
        End With
                
        With Object o5 := ComboBox():New()
            :Parent := qW
            :items  := { "item 1", "item 2", "item 3" }
        End With

        With Object o6 := MonthCalendar():New()
            :Parent := qW
        End With

        With Object o7 := Slider():New()
            :Parent := qW
        End With

        With Object o8 := ProgressBar():New()
            :Parent := qW
        End With

        With Object o9 := grid():New()
            :Parent := qW
            :Row := 3
            :Col := 3
            :ColumnHeaders := { "h1", "h2", "h3" }
            :items := { { "row 1", "row 2", "row 3" }, { "c1" ,"c2", "c3"} }
        End With

        qW:CentralWidgetOf( oWindow )

    End Window

    Activate Window oWindow

Return

function proviamo( o )

    qL := QFormLayout()
    qL:addRow( "Field of a long long label:", o1:oQTObject )
    qL:addRow( "Field1:", o2:oQTObject )
    qL:addRow( "CheckBox:", o3:oQTObject )
    qL:addRow( "Field4:", o4:oQTObject )
    qL:addRow( "ComboBox:", o5:oQTObject )
    qL:addRow( "MonthCalendar:", o6:oQTObject )
    qL:addRow( "Slider:", o7:oQTObject )
    qL:addRow( "ProgressBar:", o8:oQTObject )
    qL:addRow( "Grid:", o9:oQTObject )

    o9:AddItem( { "1", "2","3" } )
    o9:oQTObject:setRowCount( 3 )
    o9:oQTObject:setColumnWidth( 0, 55 )
    o9:oQTObject:setColumnWidth( 1, 85 )
    o9:oQTObject:setColumnWidth( 2, 115 )
    

    qW:oQTObject:setLayout( qL )

return .T.

mrduck
Posts: 497
Joined: Fri Sep 10, 2010 5:22 pm

Re: Other studies on layout

Post by mrduck »

QGridLayout..... t4d.prg

should I commit this sample code ?

Code: Select all


/*

 HMG 4 DEMO
 (c) 2010 Roberto Lopez <mail.box.hmg@gmail.com>

*/

#include "../../include/hmg.ch"
#include "hbqtgui.ch"

Function Main
    qL := NIL
    qW := NIL
    o1 := NIL
    o2 := NIL

	Define Window oWindow				;
		At 20 , 10				;
		Width	1000				;
		Height	550				;
		Title	'QGridLayout test'		;
		Main					;
		On Init { || proviamo(oWindow) } 
	
        qW := Widget():New()	

        With Object oL1 := label():New()
            :Parent := qW
            :Value    := 'Font style'
        End With

        With Object oL2 := label():New()
            :Parent := qW
            :Value    := 'Size'
        End With

        With Object oL3 := label():New()
            :Parent := qW
            :Value    := 'Font'
        End With

        With Object oT1 := textbox():New()
            :Parent := qW
            :Value := ""
        End With
                
        With Object oT2 := textbox():New()
            :Parent := qW
            :Value := ""
        End With
                
        With Object oT3 := textbox():New()
            :Parent := qW
            :Value := ""
        End With
                
        With Object oLB1 := ListBox():New()
            :Parent := qW
            :items  := { "times", "helvetica", "palatino" }
        End With

        With Object oLB2 := ListBox():New()
            :Parent := qW
            :items  := { "roman", "italic", "oblique" }
        End With

        With Object oLB3 := ListBox():New()
            :Parent := qW
            :items  := { "1", "2", "3" }
        End With

        qW:CentralWidgetOf( oWindow )

    End Window

    Activate Window oWindow

Return

function proviamo( o )

    qL := QGridLayout( )
    qL:addWidget( oL1:oQTObject, 1, 1 )
    qL:addWidget( oL2:oQTObject, 1, 3 )
    qL:addWidget( oL3:oQTObject, 1, 5 )

    qL:addWidget( oT1:oQTObject, 2, 1 )
    qL:addWidget( oT2:oQTObject, 2, 3 )
    qL:addWidget( oT3:oQTObject, 2, 5 )

    qL:addWidget( oLB1:oQTObject, 3, 1 )
    qL:addWidget( oLB2:oQTObject, 3, 3 )
    qL:addWidget( oLB3:oQTObject, 3, 5 )

    qL:setColumnMinimumWidth ( 2, 15 )
    qL:setColumnMinimumWidth ( 4, 15 )

    qL:setColumnStretch( 1, 5 )
    qL:setColumnStretch( 3, 5 )
    qL:setColumnStretch( 5, 1 )

    qW:oQTObject:setLayout( qL )

return .T.

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

Re: Other studies on layout

Post by Rathinagiri »

Yes please Francesco.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
Post Reply