QWidget

Widgets in a Main Window

The following example shows how to create some widgets in a main window. The widgets contain buttons. If you have to move the buttons, simply move the widget only. The Main Window is the parent of the widgets. The widgets are the parent of the buttons.



PROCEDURE Main()

   LOCAL oWnd
   LOCAL oGroup1,oGroup2,oGroup3
   LOCAL oButton1,oButton2,oButton3
   LOCAL oButton4,oButton5,oButton6
   LOCAL oButton7,oButton8,oButton9

   oWnd := QMainWindow()
   oWnd:setWindowTitle( "Giovanni" )
   oWnd:resize( 650, 400 )

   oGroup1 := QWidget(oWnd)
   oGroup1:resize( 150, 300 )
   oGroup1:move( 50, 50 )
   oGroup1:setStyleSheet( " background: #CCCCFF; " )

   oGroup2 := QWidget(oWnd)
   oGroup2:resize( 150, 300 )
   oGroup2:move( 250, 50 )
   oGroup2:setStyleSheet( " background: #CCFFCC; " )

   oGroup3 := QWidget(oWnd)
   oGroup3:resize( 150, 300 )
   oGroup3:move( 450, 50 )
   oGroup3:setStyleSheet( " background: #FFCCCC; " )

   oButton1 := QPushButton( oGroup1 )
   oButton1:setText( "Push" )
   oButton1:move( 25, 50 )
   oButton1:resize( 100, 30 )
   oButton1:setStyleSheet( " background: #FFAAAA; " )

   oButton2 := QPushButton( oGroup1 )
   oButton2:setText( "Push" )
   oButton2:move( 25, 100 )
   oButton2:resize( 100, 30 )
   oButton2:setStyleSheet( " background: #AAFFAA; " )

   oButton3 := QPushButton( oGroup1 )
   oButton3:setText( "Push" )
   oButton3:move( 25, 150 )
   oButton3:resize( 100, 30 )
   oButton3:setStyleSheet( " background: #AAAAFF; " )

   oButton4 := QPushButton( oGroup2 )
   oButton4:setText( "Push" )
   oButton4:move( 25, 50 )
   oButton4:resize( 100, 30 )
   oButton4:setStyleSheet( " background: #FFAAAA; " )

   oButton5 := QPushButton( oGroup2 )
   oButton5:setText( "Push" )
   oButton5:move( 25, 100 )
   oButton5:resize( 100, 30 )
   oButton5:setStyleSheet( " background: #AAFFAA; " )

   oButton6 := QPushButton( oGroup2 )
   oButton6:setText( "Push" )
   oButton6:move( 25, 150 )
   oButton6:resize( 100, 30 )
   oButton6:setStyleSheet( " background: #AAAAFF; " )

   oButton7 := QPushButton( oGroup3 )
   oButton7:setText( "Push" )
   oButton7:move( 25, 50 )
   oButton7:resize( 100, 30 )
   oButton7:setStyleSheet( " background: #FFAAAA; " )

   oButton8 := QPushButton( oGroup3 )
   oButton8:setText( "Push" )
   oButton8:move( 25, 100 )
   oButton8:resize( 100, 30 )
   oButton8:setStyleSheet( " background: #AAFFAA; " )

   oButton9 := QPushButton( oGroup3 )
   oButton9:setText( "Push" )
   oButton9:move( 25, 150 )
   oButton9:resize( 100, 30 )
   oButton9:setStyleSheet( " background: #AAAAFF; " )

   oWnd:show()
   QApplication():exec()

   RETURN