hmg4 centralwidget, windows virtualized

Moderator: Rathinagiri

Post Reply
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

hmg4 centralwidget, windows virtualized

Post by l3whmg » Sat Oct 29, 2011 2:33 pm

Hi friends.
Many times we have spoken about managing a central widget.
You can find here viewtopic.php?f=32&t=2087&hilit=centralwidget or
here viewtopic.php?f=32&t=2034&p=17281&hilit ... get#p17281
But I think not many people has a clear idea about its benefits.

To show benefits about usage of a centralwidget, I have realized two sample programs with my experimental version (it's not hmg4).
The great difference with current HMG4 is that:
  • 1) by default every window has a central widget.
  • 2) Every control defined has the central widget as parent (if parent is defined. When defined: if parent has a central widget else the Qt object)
A) General great benefit.
Graph.exe it's derived from samples/graph/demo_5.prg. I removed all buttons and I have added: one menu (fontsize 12), a toolbar (fontsize 12, buttonwidth 60, buttonheight 40) and statusbar (fontsize 12). Everyone can do the same changes and compare both programs.
After run program, you must DRAW a graph; then, you must move toolbar everywhere. As you will see, the GRAPH is moved automatically and it doesn't overlap the toolbar, the menu or statusbar.

B) Window virtual dimensions.
Scrollform.exe Just using a centralwidget I can create a virtualized window. After run program, play with bars or enlarge window to hide bars

C) Layouts.
I found an alternative way to handle and use layouts but, for me, it's very hard for some reasons:knowledge about Qt layouts, this technique it's so different. Anyway I'm doing test and for this reason I can only show a piece of end program (it work :mrgreen: ) and related image. This solution it's very, very experimental.

Code: Select all

STATIC FUNCTION TestGridLayout()

   WITH OBJECT MainForm := WINDOW():New()
      :Width   := 600
      :Height  := 600
      :Row     := 50
      :Col     := 50
      :Title   := "form title"

      WITH OBJECT GRIDLAYOUT():New()
         :Spacing    := 3
         :MinWidthCol( 1, 100 )
         :MinWidthCol( 3, 250 )
      END WITH

      WITH OBJECT LABEL():New( "label1" )
         :Row        := 1
         :Col        := 1
         :Caption    := "Label1"
         :BackColor  := {0, 255, 0}
      END WITH

      WITH OBJECT BUTTON():New( "button1" )
         :Row     := 1
         :Col     := 3
         :Caption := "Exit1"
         :OnClick := { || MainFrmExit() }
      END WITH

      WITH OBJECT LABEL():New( "label2" )
         :Row     := 5
         :Col     := 2
         :Caption := "Label2"
         :BackColor  := {204, 255, 102}
      END WITH

      WITH OBJECT BUTTON():New( "button2" )
         :Row     := 5
         :Col     := 4
         :Caption := "Message"
         :OnClick := { || MsgStop( "I'm button2") }
      END WITH

   END WITH

   MainForm:Activate()

   MainForm := NIL

RETURN NIL
ScreenShot002.jpg
ScreenShot002.jpg (5.28 KiB) Viewed 854 times
This one want manage more then one layout

Code: Select all

STATIC FUNCTION TestMulti01()

   WITH OBJECT MainForm := WINDOW():New()
      :Width   := 600
      :Height  := 600
      :Row     := 50
      :Col     := 50
      :Title   := "form title"

      WITH OBJECT BOXLAYOUT():New()
         :Direction  := QBoxLayout_TopToBottom
      END WITH

      WITH OBJECT LABEL():New( "label0" )
         :Row        := 1
         :Col        := 1
         :Caption    := "Label0"
         :BackColor  := {200, 200, 200}
      END WITH

      WITH OBJECT GRIDLAYOUT():New()
         :Spacing    := 3
         :MinWidthCol( 2, 100 )
      END WITH

      WITH OBJECT LABEL():New( "label1" )
         :Row        := 1
         :Col        := 1
         :Caption    := "Label1"
         :BackColor  := {0, 255, 0}
      END WITH

      WITH OBJECT BUTTON():New( "button1" )
         :Row     := 1
         :Col     := 3
         :Caption := "Exit1"
         :OnClick := { || MainFrmExit() }
      END WITH

   END WITH

   MainForm:Activate()

   MainForm := NIL

RETURN NIL
Best regards
Attachments
LqtGui.zip
executable examples
(2.05 MiB) Downloaded 79 times
Luigi from Italy
www.L3W.it

Post Reply