About windows in hmg3, 4 and qt
Moderator: Rathinagiri
About windows in hmg3, 4 and qt
I'm trying to understand which kind of windows can be defined in hmg3 and how we can map them in hmg4/qt.
I see in the hmg3 source files that we may have WINDOWTYPE
MAIN (there must be ONLY ONE such window type), CHILD, MODAL, STANDARD, SPLITCHILD. Some checks are done to be sure that we respect some limits.
In the only source code of a real application (thanks Mol) developed in hmg3 I see a lot of MODAL windows and just one CHILD... anyway, other programmers may have different needs.
Now I ask to the other developers using hmg3: do you actually use all these windows types ? can you please show me samples ?
Now to Qt.
In Qt there is no concept of "main window"... actually we may have any widget as the "main window"... or can be a QDialog...
There is a QMainWindow that can serve as the "main" window. A QMainWindow may have a relocatable toolbar, statusbar, menu, relocatable docks (panels) but in order to work without problems IT NEEDS/WANTS a central widget defined, so that moving toolbars, resizing window, etc Qt can do correctly its job.
As I said, QMainWindow is perfect for hmg4 WINDOWTYPE MAIN (except for the central widget that we now have to specify manually while we should do automatically in hmg4 code). Check at http://doc.qt.nokia.com/latest/qmainwindow.html
It's also good for WINDOWTYPE MODAL and also in this case we should set the centralwidget.
What about CHILD, SPLITCHILD and STANDARD windows ? I'm trying to understand how they work, they are used in some hmg3 samples... but are they really used in "real" code ?
So, according to HMG3 docs and code, we must check that the first defined window is of MAIN type and exit the program otherwise. We should also add a qWidget to be used as the central widget of the windows.
Francesco
I see in the hmg3 source files that we may have WINDOWTYPE
MAIN (there must be ONLY ONE such window type), CHILD, MODAL, STANDARD, SPLITCHILD. Some checks are done to be sure that we respect some limits.
In the only source code of a real application (thanks Mol) developed in hmg3 I see a lot of MODAL windows and just one CHILD... anyway, other programmers may have different needs.
Now I ask to the other developers using hmg3: do you actually use all these windows types ? can you please show me samples ?
Now to Qt.
In Qt there is no concept of "main window"... actually we may have any widget as the "main window"... or can be a QDialog...
There is a QMainWindow that can serve as the "main" window. A QMainWindow may have a relocatable toolbar, statusbar, menu, relocatable docks (panels) but in order to work without problems IT NEEDS/WANTS a central widget defined, so that moving toolbars, resizing window, etc Qt can do correctly its job.
As I said, QMainWindow is perfect for hmg4 WINDOWTYPE MAIN (except for the central widget that we now have to specify manually while we should do automatically in hmg4 code). Check at http://doc.qt.nokia.com/latest/qmainwindow.html
It's also good for WINDOWTYPE MODAL and also in this case we should set the centralwidget.
What about CHILD, SPLITCHILD and STANDARD windows ? I'm trying to understand how they work, they are used in some hmg3 samples... but are they really used in "real" code ?
So, according to HMG3 docs and code, we must check that the first defined window is of MAIN type and exit the program otherwise. We should also add a qWidget to be used as the central widget of the windows.
Francesco
Re: About windows in hmg3, 4 and qt
Hi MrDuck.
With my little programs I use: one MAIN WINDOW, a LOT of STANDARD/CHILD forms and few MODAL window. This, because (basically) with MODAL I can open only a new MODAL form. It's not very easy to manage several STANDARD/CHILD form, but with good code can be do.
Cheers
With my little programs I use: one MAIN WINDOW, a LOT of STANDARD/CHILD forms and few MODAL window. This, because (basically) with MODAL I can open only a new MODAL form. It's not very easy to manage several STANDARD/CHILD form, but with good code can be do.
Cheers
Luigi from Italy
www.L3W.it
www.L3W.it
-
- Posts: 245
- Joined: Sat Aug 02, 2008 5:03 pm
Re: About windows in hmg3, 4 and qt
Hi
I'm using CHILD, MODAL, STANDARD, most of them are modal and child with NoAutoRelease Style, and NO SPLITCHILDs
Notes from Roberto in hmg docs.
Maybe the sample: Hmg\SAMPLES\MAIN.DEMO\DEMO.PRG can give you an idea about childsmrduck wrote: Now I ask to the other developers using hmg3: do you actually use all these windows
types ? can you please show me samples ?
I'm using CHILD, MODAL, STANDARD, most of them are modal and child with NoAutoRelease Style, and NO SPLITCHILDs
Notes from Roberto in hmg docs.
SplitBox in QT is really different than MS windows style. In my opinion SPLITCHILD is not compatible with HMG4.- SplitChild windows can be defined as part of a splitbox only.
- Toolbar's & SplitBox's parent window can't be a 'Virtual Dimensioned'
window (use 'Virtual Dimensioned' splitchild's instead)
- NoAutoRelease Style: When this style is used, windows are hide
instead released from memory when the user clicks in the close box.
Using "Activate Window All" command at program startup will force
"NoAutoRelease" style for all windows (excepting main).
You must use "Show" and "Hide" methods to make a window visible or invisible.
Any hint about those problems. I'm testing HBQT directly (to understand and learn about it) and I can´t see them right now.In Qt there is no concept of "main window"... actually we may have any widget as
the "main window"... or can be a QDialog...
There is a QMainWindow that can serve as the "main" window. A QMainWindow may
have a relocatable toolbar, statusbar, menu, relocatable docks (panels) but in
order to work without problems IT NEEDS/WANTS a central widget defined, so that
moving toolbars, resizing window, etc Qt can do correctly its job.
Regards/Saludos, Carlos (bcd12a)
Re: About windows in hmg3, 4 and qt
Carlos Britos wrote:HiAny hint about those problems. I'm testing HBQT directly (to understand and learn about it) and I can´t see them right now.mrduck wrote: A QMainWindow may
have a relocatable toolbar, statusbar, menu, relocatable docks (panels) but in
order to work without problems IT NEEDS/WANTS a central widget defined, so that
moving toolbars, resizing window, etc Qt can do correctly its job.
Compile this code
Code: Select all
#include "hbqtgui.ch"
#include "../../include/hmg.ch"
#define CENTRAL
procedure main
PRIVATE oMainWnd
PRIVATE oTB
private qqWW,o1,o2
hbqt_errorsys()
Define Window oMainWnd ;
At 20 , 10 ;
Width 900 ;
Height 570 ;
Title 'central widget test' ;
Main
CreateToolbar( oMainWnd )
#ifdef CENTRAL
qqWW := Widget():New()
@ 10, 10 LABEL o1 OF qqWW VALUE "label 1 central"
@ 30, 30 LABEL o2 OF qqWW VALUE "label 2 central"
qqWW:CentralWidgetOf( oMainWnd )
#else
@ 10, 10 LABEL o1 VALUE "label 1 NO CENTRAL"
@ 30, 30 LABEL o2 VALUE "label 2 NO CENTRAL"
#endif
End Window
Activate Window oMainWnd
STATIC FUNCTION CreateToolbar( oWnd )
With Object oTB := ToolBar():New()
With Object oButton1 := ToolButton():New()
:Parent := oTB
:Caption := 'New'
End With
With Object oButton2 := ToolButton():New()
:Parent := oTB
:Caption := 'Open'
End With
end with
Then edit the file and put a // before the #define, compile and run it again....
As you can see in the first case the LABELs are children of a widget and this widget is set as the central widget of the main window. In this way Qt can relocate it when needed.
In the second case the LABELs are children of the main window... of course you can give them a greater coordinate to skip the toolbar... but if you move the toolbar you have an empty space... or you may forbid to move the toolbar... anyway you have a coordinate that is not "proper"...
What I propose is to automatically create a QWidget, assign it as the central widget and then set it as the standard parent.... (is it possible with today code????)
-
- Posts: 245
- Joined: Sat Aug 02, 2008 5:03 pm
Re: About windows in hmg3, 4 and qt
Okmrduck wrote: Then edit the file and put a // before the #define, compile and run it again....
As you can see in the first case the LABELs are children of a widget and this widget is set as the central widget of the main window. In this way Qt can relocate it when needed.
In the second case the LABELs are children of the main window... of course you can give them a greater coordinate to skip the toolbar... but if you move the toolbar you have an empty space... or you may forbid to move the toolbar... anyway you have a coordinate that is not "proper"...
Some time I tried on the implementation of layouts ,but with no luck, maybe now is possibleWhat I propose is to automatically create a QWidget, assign it as the central widget and then set it as the standard parent.... (is it possible with today code????)
Regards/Saludos, Carlos (bcd12a)
Re: About windows in hmg3, 4 and qt
Hi guys. This suggestion it is very interesting and use of layout it is important, but as Carlos write: difficult to understand and manage. On the other hand, I discovered that: QmainWIndow has some default widget: central, statusbar, menubar
and you can add here something, but at the same time, I discovered that you can't assign a widget to another widget with
oWidget1:addwidget(oWidget2) and, perhaps, we must use layout. I'm little confused: I can add a QLabel (is this a widget?) to the centralwidget but I must use a layout in other case ????
I try this code to create a scrollable area within central widget of a QMainWindow. No complete because I don't understand something: it's seem to work but....
and you can add here something, but at the same time, I discovered that you can't assign a widget to another widget with
oWidget1:addwidget(oWidget2) and, perhaps, we must use layout. I'm little confused: I can add a QLabel (is this a widget?) to the centralwidget but I must use a layout in other case ????
I try this code to create a scrollable area within central widget of a QMainWindow. No complete because I don't understand something: it's seem to work but....
Code: Select all
#include "hbqtgui.ch"
STATIC s_oQtApp
STATIC s_oQtResource
MEMVAR oMainForm
FUNCTION Main
LOCAL cRes := "HBQTRES_STDICON()"
hbqt_errorsys()
s_oQtApp := QApplication()
s_oQtResource := QResource()
s_oQtResource:registerResource_1( &cRes )
oMainForm := QMainWindow()
oMainForm:setWindowTitle( "Very simple test" )
oMainForm:setWindowIcon( ":L3W_ICO" )
oMainForm:resize( 600, 600 )
oMainForm:move( 20,20 )
ShowMainForm()
s_oQtResource:unregisterResource_1( &cRes )
s_oQtApp:quit()
RETURN NIL
STATIC FUNCTION ShowMainForm()
LOCAL oQtMainFrmCentralWidget := oMainForm:centralWidget()
LOCAL oQtLabelTitle1, oQtLabelTitle2
LOCAL oQtScrollArea
LOCAL oQtLayout
// LOCAL oQtGridLayout
oQtScrollArea := QScrollArea( oQtMainFrmCentralWidget )
oQtScrollArea:setBackgroundRole(QPalette_Dark)
oQtScrollArea:setHorizontalScrollBarPolicy( Qt_ScrollBarAlwaysOn )
oQtScrollArea:setVerticalScrollBarPolicy( Qt_ScrollBarAlwaysOn )
oQtScrollArea:setWidgetResizable( .T. )
oQtScrollArea:resize(900,900)
oMainForm:setCentralWidget( oQtScrollArea )
oQtLayout := QBoxLayout( oQtScrollArea )
// oQtScrollArea:setLayout( oQtLayout )
oQtLabelTitle1 := QLabel( "Title", oQtScrollArea )
oQtLabelTitle1:resize(100, 20)
oQtLabelTitle1:move(100, 100)
oQtLabelTitle1:setStyleSheet("background-color:#FF0000")
oQtLayout:addWidget( oQtLabelTitle1 )
oQtLabelTitle2 := QLabel( "Title", oQtScrollArea )
oQtLabelTitle2:resize(100, 20)
oQtLabelTitle2:move(100, 600)
oQtLabelTitle2:setStyleSheet("background-color:#FF00FF")
oQtLayout:addWidget( oQtLabelTitle2 )
oQtScrollArea:setLayout( oQtLayout )
oMainForm:Show()
s_oQtApp:exec()
RETURN NIL
Luigi from Italy
www.L3W.it
www.L3W.it
Re: About windows in hmg3, 4 and qt
Hi guys.
MrDuck is a great man.
He has managed to make working my discovery, I think this allows us to add the ability to have a scrollable form. In other words, a form with virtual dimensions. This is the running source code: obviously pure HbQt.
This example, however, shows that HMG4 is still in a highly evolution.
The proof can be found by analyzing the source code: it is not an obligation, but the adoption of a widget in the main form is extremely useful.
IMHO, we must spend time to find, check, try and rewrite.
Cheers
MrDuck is a great man.
He has managed to make working my discovery, I think this allows us to add the ability to have a scrollable form. In other words, a form with virtual dimensions. This is the running source code: obviously pure HbQt.
Code: Select all
#include "hbqtgui.ch"
STATIC s_oQtApp
STATIC s_oQtResource
MEMVAR oMainForm
FUNCTION Main
hbqt_errorsys()
s_oQtApp := QApplication()
oMainForm := QMainWindow()
oMainForm:setWindowTitle( "Very simple test" )
// oMainForm:resize( 600, 600 )
oMainForm:move( 20,20 )
ShowMainForm()
s_oQtApp:quit()
RETURN NIL
STATIC FUNCTION ShowMainForm()
LOCAL oQtMainFrmCentralWidget := oMainForm:centralWidget()
LOCAL oQtLabelTitle1, oQtLabelTitle2
LOCAL oQtScrollArea
LOCAL oW
oW := qWidget()
oW:setBackgroundRole(QPalette_Light)
oW:setSizePolicy( QSizePolicy_Minimum, QSizePolicy_Minimum )
oQtLabelTitle1 := QLabel( "111111111111111", oW )
oQtLabelTitle1:resize(100, 20)
oQtLabelTitle1:move(100, 100)
oQtLabelTitle1:setStyleSheet("background-color:#FF0000")
oQtLabelTitle2 := QLabel( "22222222222222", oW )
oQtLabelTitle2:resize(100, 20)
oQtLabelTitle2:move(100, 600)
oQtLabelTitle2:setStyleSheet("background-color:#FF00FF")
oW:adjustSize()
oQtScrollArea := QScrollArea( )
oQtScrollArea:setBackgroundRole(QPalette_Dark)
oQtScrollArea:setHorizontalScrollBarPolicy( Qt_ScrollBarAlwaysOn )
oQtScrollArea:setVerticalScrollBarPolicy( Qt_ScrollBarAlwaysOn )
oQtScrollArea:setWidget( oW )
oMainForm:setCentralWidget( oQtScrollArea )
oMainForm:Show()
s_oQtApp:exec()
RETURN NIL
The proof can be found by analyzing the source code: it is not an obligation, but the adoption of a widget in the main form is extremely useful.
IMHO, we must spend time to find, check, try and rewrite.
Cheers
Luigi from Italy
www.L3W.it
www.L3W.it
Re: About windows in hmg3, 4 and qt
Hey you...
After doing some tests I managed to make a central widget the window object.
Download the http://www.farmacia.com.br/everything_demo_1.exe put in the samples\everything, run and play with the toolbars.
It needs some refinement but first I need your comments about.
After doing some tests I managed to make a central widget the window object.
Download the http://www.farmacia.com.br/everything_demo_1.exe put in the samples\everything, run and play with the toolbars.
It needs some refinement but first I need your comments about.
[[]] Mauricio Ventura Faria
Re: About windows in hmg3, 4 and qt
Hi Mauricio,
please post the source code of the sample (and the modified code of hmg)
thanks
please post the source code of the sample (and the modified code of hmg)
thanks
concentra wrote:Hey you...
After doing some tests I managed to make a central widget the window object.
Download the http://www.farmacia.com.br/everything_demo_1.exe put in the samples\everything, run and play with the toolbars.
It needs some refinement but first I need your comments about.
Re: About windows in hmg3, 4 and qt
Hi.
In Hmg itself what I did:
-instantiate a QWidget in the window class and this QWidget became the ::oQtObject;
-the former ::oQtObject, QMainWindow, was renamed to ::oQtWindowWidget;
-in this approach some controls must inherit from ::oQtObject and others from ::oQtWindowWidget, but only when the parent is from WINDOW class. So I had to manage the inheritance in mainmenu, statusbar and toolbar, controls that are docked outside the central widget.
-few methods in window class that references ::oQtObject needed to be overloaded to reference ::oQtWindowObject, row, col, width and height. Possibly some few others.
The sample was untouched.mrduck wrote:Hi Mauricio,
please post the source code of the sample (and the modified code of hmg)
In Hmg itself what I did:
-instantiate a QWidget in the window class and this QWidget became the ::oQtObject;
-the former ::oQtObject, QMainWindow, was renamed to ::oQtWindowWidget;
-in this approach some controls must inherit from ::oQtObject and others from ::oQtWindowWidget, but only when the parent is from WINDOW class. So I had to manage the inheritance in mainmenu, statusbar and toolbar, controls that are docked outside the central widget.
-few methods in window class that references ::oQtObject needed to be overloaded to reference ::oQtWindowObject, row, col, width and height. Possibly some few others.
[[]] Mauricio Ventura Faria