I Pritpal,
I spent some days to investigate and coding...
In attachement, you will find a simple program and an update of HBQValidator, if you find it worthwhile.
The program is very simple: based on the style (see comboBox) the lineEdit text is different both using setText while editing.
Regarding to OS, Harbour and Qt, remember that I'm Italian.
ALERT: you must replace lw_Trace(...) function with your preferred, to write text into an external file.
ALERT_2: I've aligned Harbour codepage to OS (see ThisInit() ) otherwise (f.e.) "à" is "..." translated
WARNING: to build program, I add this lines to .hbp
-pflag=-qtver=0x040500
-pflag=-qtmodule=qtgui
-pflag=-qthdocdir=../doc/
-i.
-i${HB_WITH_QT}
-cflag=-std=c++11Before describing the differences between HBQValidator and XFQValidator, I report below some observations made using the program
A) solution: AFAIK the normal way if I understand Qt docs.
Warning: to run this solution, you need to change from "if( 0==1 )" to "if( 0==0 )" in oop001.prg
1) It seems that using ::setText( txt ) where txt is equal to ::text()
the
::validate(...)
is NOT fired on; you need to follow 3.1)
2) using :setText( txt ) where ::validate(...) returns QValidator::Intermediate (from HbQValidator pov is NIL or {text, pos, NIL))
the ::fixup(...) function is NOT fired on, I think due to Qt (only my version???)
3.1) only when you leave the field (i.e. press <TAB> or <RETURN>), the ::fixup() is execute
and ::validate() functions is execute 2 times (I don't know why)
but
3.2) while you are editing the field and for some reason ::validate() returns QValidator::Intermediate, no ::fixup() call is execute.
You must leave the field, see 3.1)
, I think due to Qt (only my version???)
B) solution: using a trick.
Warning: to run this solution, you need to change from "if( 0==0 )" to "if( 0==1 )" in oop001.prg
The trick is to call ::fixup() "code" into ::validate() :-)) but remember the 1)
The difference with "A) solution" is that while you are edit the field is immediately update.
Obviously, the ::fixup() "code" is call everytime ::validate() is execute, so the ::fixup() procedure call is never do.
This seems to be (more or less) the solution adopted/suggested by PyQt.
HBQValidator vs XFQValidator differences (I have used different names only to be able to run both versions).
a)
I used input.toUtf8().data() for both ::validate() and ::fixup() without problems,
People speaking different language than mine, can build and run program and report problems.
b) A parent can be given, so the constructor can be
xxValidator() read b.1)
xxValidator( parent ) read b.1)
xxValidator( validateBlock )
xxValidator( validateBlock, parent )
xxValidator( validateBlock, fixupBlock ) as current version
xxValidator( validateBlock, fixupBlock, parent )
b.1) due to constructors, there is hbSetBlocks( validateBlock, fixupBlock )
ALERT usage: hbSetBlocks() removes both validate and fixup block
hbSetBlocks( validateBlock ) removes fixup and set validate block
hbSetBlocks( NIL, fixupBlock ) removes validate and set fixup block
hbSetBlocks( validateBlock, fixupBlock ) set both blocks
Little aside question:why these declarations
PHB_ITEM pValidBlk;
PHB_ITEM pFixupBlk;must be declared as "public" within xxxx.h file?
I tried
private:
PHB_ITEM pValidBlk;
PHB_ITEM pFixupBlk;but I get compilation errors. I'm not a C programmer :-))
Best regards
Luigi