bug in toolbar.prg -> addToolbar

Moderator: Rathinagiri

Post Reply
JosK
Posts: 46
Joined: Tue Nov 08, 2011 11:38 pm

bug in toolbar.prg -> addToolbar

Post by JosK » Sun Dec 11, 2011 10:31 am

i have delete line's 93-98 in toolbar.prg
if hb_isobject(::oParent)
::cParent:QtObject:addToolbar(::QTobject)
endif

in myPrg.prg:
o:Toolbar():New(c,oParent)

oParent=tabpage

Error was "addToolbar line 94"

After deleting the lines .. now i have a Toolbar on my Tabpage
This is myPrg.prg (jkGrid is a copy of visualgrid):

#include "hmg.ch"
#include "hbqtgui.ch"
#include "hbgtinfo.ch"
#include "std.ch"

SET DATE TO ANSI
SET EPOCH TO 1950 //KAN OOK CENTURY DOEN MAAR DAN 4 POSITIES..
SET CENTURY OFF
SET WRAP ON && ref 'menu to ...'
SET TALK OFF &&
SET BELL OFF &&
SET DELETED ON &&
SET SAFETY OFF &&
SET HEADING OFF &&
SET DELIMITERS OFF &&
SET SCOREBOARD OFF && geen Num, Ins, enz op lijn 0.
SET INTENSITY ON
SET DELIMITERS OFF
SET EXACT OFF
SET CURSOR OFF //KENT HMG NIET daar std.ch
SET DELETED ON && alleen btw bestand word direct gepackt ivm reccount()
SET EXCLUSIVE ON
setcancel(.f.)


FUNCTION Main()

//Public oTP1,oTP2
//Public oTLB //oTabpageLayoutBox -> local in oTP1

HbQt_ErrorSys()

wMain :=MaakMain("wMain")
oCW :=Widget():New("oCW",wMain)
oCW :CentralWidgetOF(wMain)
oLB :=LayoutBox():New("oLB",oCW,LAYOUT_TOPTOBOTTOM)
with object oTab:=Tab():New("oTab")
oTP1:=MaakTP1("oTP1",oTab)
oTP2:=MaakTP2("oTP2",oTab)

end
oLB:add(oTab)
oLB:SetLayout()
ON KEY F10 OF WMAIN ACTION {|| MSGSTOP("f10 binnen wmain")}
ON KEY F8 OF WMAIN ACTION {|| MSGSTOP( str( oTP1.oTLB:direction()))}
//0=l->r, 1=r-l, 2=t-b, 3=b-t, 4=form, 5=grid
ON KEY F9 OF WMAIN ACTION {|| if( (x:=oTP1.oTLB:Direction()) ==3, oTP1.oTLB:Directon(0), oTP1.oTLB:Direction(x+1) )}
//F9 heeft geen invloed op child olF onder oTLB
ON KEY F7 OF WMAIN ACTION {|| x:=oTP2.oBrowse:ColumnWidths(),x[2]:=800,oTP2.oBrowse:ColumnWidths(x),oTP2.oBrowse:Refresh() }
ON KEY F6 OF WMAIN ACTION {|| x:=oTP2.oBrowse:ColumnHeaders(),x[2]:="TEST",oTP2.oBrowse:ColumnHeaders(x),oBrowse:Refresh() }
wMain:Activate()
Return NIL
***************************
STATIC FUNCTION MaakMain(c)
***************************
static o
if o==nil
o:= MAINWINDOW():New(c)
o:Title := "Maak Main Demo"
endif
return o
***************************************
STATIC FUNCTION MaakTab(c,oParent,nRow)
***************************************
local o
o:=Tab():New(c,oParent)
return o
***************************
FUNCTION MaakTP1(c,oParent)
***************************
local oTLB,oBrowse,oTB
static o
if o=Nil
//indien meerdere items op horizontaal is apart frame
// auto van 1/2 lines gaat niet lukken naar groot/klein scherm
o:=TabPage():New(c,oParent)
o:caption:="&Tabpage1"
oTLB:=LayoutBox():New("oTLB",o)
oTLB:direction(2) //t-b

oTB:=maakToolBar("oTB",o)

oBrowse:=MaakBrowse("oBrowse",o)

oLF:=Layoutform():New("oLF",oTLB)
oB1:=Button():New()
oB1:caption("Button1")
oT1:=TextBox():New()
oB2:=Button():New()
oB3:=MaakBtn("oB3")
oLF:add(oB1)
oLF:add(oT1)
oLF:add(oB2)
oLF:add(oB3)
oTLB:addlayout(oLF)
oTLB:add(oBrowse)
oTLB:add(oTB)
oTLB:stretch(1,20)
oTLB:stretch(2,80)
oTLB:setlayout()
endif
return o

************
STATIC FUNCTION MaakBtn(c,oParent)
************
static o
o:=Button():New(c,oParent)
o:MaxWidth :=300
o:Caption := "Current Language"
o:OnClick := { || Bt1_OnClick() }
RETURN o
************
STATIC FUNCTION Bt1_OnClick()
************
MsgInfo( "Current Language is " + hb_ValToExp( HMGAPP():Language() ), "Language" )
RETURN NIL

***************************
FUNCTION MaakTP2(c,oParent)
local oTLB,oBrowse
static o
//go top

if o=Nil
o:=TabPage():New(c,oParent)
o:caption:="&RekSchema"
oTLB:=LayoutBox():New("oTLB",o,LAYOUT_TOPTOBOTTOM)
oBrowse:=MaakBrowse("oBrowse",o)
oTLB:add(oBrowse)
oTLB:setlayout()
endif
return o
**********************
function MaakBrowse(c,oParent)
**********************
static o
static bColor := { || IF ( ordkeyno()/2 == INT(ordkeyno()/2) , { 222,222,222 } , { 255,255,255 } ) }
static fColor := { || IF ( ordkeyno()/2 == INT(ordkeyno()/2) , { 255,0,0 } , { 0,0,255 } ) }
use c:\hmg.4\svn\samples\t\demo alias demo
//o:=jkGrid():New(c,oParent)
o:=jkGrid():New(c,oParent)
/*
o:Row := 10
o:Col := 10
o:Width := 690
o:Height := 615
*/
o:WorkArea := 'demo'
//o:OnChange :={||MsgInfo( "Andere cell/regel geselecteerd!" )}
//o:ONDBLClick :={||MsgInfo( "We gaan cell editten!" )}


* 'First','Last','Street','City','State','Zip','Hire Date','Married' ,'Age', Salary' , 'Notes'}
* '1,2,3,4,5,6Zip,7H,8'Married',9Age',10Salary' , 11Notes'}
//kreeg een error er daarom columnHeader toegevoegd
o:ColumnHeaders := { 'First' , 'Last' , 'Street' , 'City' , 'State' , 'Zip' , 'HireDate' , 'Married' , 'Age' , 'Salary' , 'Notes' }
o:ColumnFields := { 'First' , 'Last' , 'Street' , 'City' , 'State' , 'Zip' , 'HireDate' , 'Married' , 'Age' , 'Salary' , 'Notes' }
o:ColumnWidths := { 150 , 150 , 150 , 150 , 150 , 150 , 150 , 150 , 150 , 150 , 150 }
// ColumnJustify {GRID_JTFY_LEFT,GRID_JTFY_RIGHT,GRID_JTFY_LEFT,GRID_JTFY_LEFT,GRID_JTFY_LEFT,GRID_JTFY_RIGHT,GRID_JTFY_LEFT}
// brw_left etc is idem als grid_jtfy_left
o:ColumnJustify := { BRW_LEFT , BRW_RIGHT , BRW_CENTER , BRW_LEFT , BRW_RIGHT , BRW_CENTER , BRW_LEFT , BRW_RIGHT , BRW_CENTER , BRW_LEFT , BRW_RIGHT }
o:DynamicBackColor := { bColor , bColor , bColor , bColor , bColor , bColor , bColor , bColor , bColor , bColor , bColor }
o:DynamicForeColor := { fColor , fColor , fColor , fColor , fColor , fColor , fColor , fColor , fColor , fColor , fColor }
o:DynamicDisplay := { { || UPPER(First) } , NIL , NIL , NIL , NIL , NIL , NIL , { || IF(married,'Married','Not Married' ) } , NIL , NIL , NIL }
o:OnHeadClick := { { || MsgInfo( 'Click 1' ) } , , { || MsgInfo( 'Click 3' ) } , { || MsgInfo( 'Click 4' ) } , { || MsgInfo( 'Click 5' ) } , { || MsgInfo( 'Click 6' ) } , { || MsgInfo( 'Click 7' ) } , { || MsgInfo( '8' ) } , ,}
o:HeaderImages := { 'new.png' , 'open.png' , 'paste.png' , 'save.png' , 'new.png' , 'open.png' , 'paste.png' , 'save.png' , 'new.png' , 'open.png' , 'paste.png' }
o:lVScrollBar := .f.
//1.1= textbox,checkbox
//1.2=nummeric,date,character
//1.3=imputmask
//1.4=format alleen bij nummeric
// justify via andere array
//1="checkbox", caption=2of3,onchange=2of3 hij checkt op wel/niet block!?
//1="datepicker",2="UPDOWN" else updown=f
//1="spinner",2=RangeMin, 3=RangeMax
//1="combobox",2=items=array

o:ColumnControls :={{'TEXTBOX','CHARACTER'},;
{'TEXTBOX','CHARACTER'},;
{'TEXTBOX','CHARACTER','@K'},;
{"SPINNER",1,1000},;
{"COMBOBOX",{"January","February","March","April","May","June","July","August","September","October","November","December"}},;
{'TEXTBOX','CHARACTER',"@K"},;
{"DATEPICKER","UpDown"},;
{'CHECKBOX','Yes','No'},;
{'TEXTBOX','NUMERIC','99'},;
{'TEXTBOX','NUMERIC','999.99'},;
{'TEXTBOX','CHARACTER'};
}
o:MultiSelect := .F. //bij true = geen edit , alleen display
o:AllowEdit := .T. //alleen indien columnControls is ingevuld
o:Lines := .F.
o:VScrollBar := .F.
o:ColumnWhen := { { || UPPER(LEFT(first,1) ) == 'A' } ,;
, , , , , , , , , , , }
//msgstop wordt bij opbouwen scherm bij iedere regel getoond
//bij when en browse problem want werd bij iedere regel werd when uitgevoerd; ook bij opbouwen scherm
//er moet een block in staan want anders error na intoetsen key
//o:ColumnWhen := { { || UPPER(LEFT(first,1) ) == 'A' } , , , , , , , , , , }
//o:ColumnValid := { { || !EMPTY(memvar.demo.first) } , , , , , , , , , { || demo->salary > 100 } , }
o:ColumnValid := { { || !EMPTY(demo.first) } , , , , , , , , , { || demo->salary > 100 } , }
o:ValidMessages := { "First name can't be EMPTY" , , , , , , , , , "Salary mus be greater than 100" , }
x1:=len(o:ColumnControls())
x2:=len(o:ColumnValid())
x3:=len(o:ValidMessages())
if x1#x2.or.x1#x3
msgstop("x1="+str(x1) + " x2="+str(x2)+ " x3="+str(x3))
endif
return o
********************************
function maakToolBar(c,oParent)
********************************
static o
if o==NIL
o:=Toolbar():New(c,oParent)
* via methode atObject:addToolBar en oParent=Tab heeft deze niet.
o:MOVEABLE := .F.
//oTB:TBARPLACE:= Qt_RightToolBarArea
with Object TOOLBUTTON():New("TB1",o)
:Caption := "Save"
:Picture := "save.png"
:OnClick := {|| MsgInfo( "Save!" )}
:ToolTip := "ToolTip"
end
with Object TOOLBUTTON():New("TB2",o)
:Caption := "Save"
:Picture := "save.png"
:OnClick := {|| MsgInfo( "Save!" )}
:ToolTip := "ToolTip"
end
end
return o

Post Reply