Valid y When

Valid y When

Postby jtscalpe » Fri Sep 08, 2017 9:01 am

Como se puede hacer un Valid y When con QlineEdit() sin usar el get ?, se puede ?, porque no veo en los ejemplos ninguna practica de lo dicho, seria como el OnChange, Onclick ......
jtscalpe
 
Posts: 18
Joined: Thu Sep 07, 2017 6:20 pm

Re: Valid y When

Postby Antonio Linares » Fri Sep 08, 2017 10:48 am

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41205
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Valid y When

Postby Antonio Linares » Fri Sep 08, 2017 11:12 am

Aqui tienes un ejemplo de como poder hacer el VALID:

Code: Select all  Expand view
#include "FiveTouch.ch"

function Main()

   local oDlg, oGet1, cTest
   local oBtnOk, oBtnCancel

   DEFINE DIALOG oDlg

   @ 20, 20 GET oGet1 VAR cTest OF oDlg SIZE 100, 20

   oGet1:Connect( "textEdited(QString)", { | u | MsgInfo( u ) } )

   @ 200, 90 BUTTON oBtnOk PROMPT "Ok" OF oDlg ;
      ACTION MsgInfo( "Ok!" )

   @ 200, 220 BUTTON oBtnCancel PROMPT "Cancel" OF oDlg ;
      ACTION oDlg:End()

   ACTIVATE DIALOG oDlg CENTERED

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41205
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Valid y When

Postby Antonio Linares » Fri Sep 08, 2017 11:15 am

Tambien podrias usar esta señal que se emite cuando se ha terminado de editar:

http://doc.qt.io/qt-4.8/qlineedit.html#editingFinished

Code: Select all  Expand view
#include "FiveTouch.ch"

function Main()

   local oDlg, oGet1, cTest
   local oBtnOk, oBtnCancel

   DEFINE DIALOG oDlg

   @ 20, 20 GET oGet1 VAR cTest OF oDlg SIZE 100, 20

   oGet1:Connect( "editingFinished()", { || MsgInfo( "VALIDar desde aqui" ) } )

   @ 200, 90 BUTTON oBtnOk PROMPT "Ok" OF oDlg ;
      ACTION MsgInfo( "Ok!" )

   @ 200, 220 BUTTON oBtnCancel PROMPT "Cancel" OF oDlg ;
      ACTION oDlg:End()

   ACTIVATE DIALOG oDlg CENTERED

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41205
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Valid y When

Postby Antonio Linares » Fri Sep 08, 2017 11:20 am

hay dos señales que se reciben de QWidget pero no se como podemos usarlas:

http://doc.qt.io/qt-4.8/qwidget.html#signals

En concreto keyboardGrabber() y mouseGrabber() servirían para hacer el WHEN
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41205
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Valid y When

Postby jtscalpe » Tue Sep 12, 2017 3:29 pm

Este Ejemplo me funciona bien para el Valid, porque en función de lo que devuelva, (.t.) o (.f.), la función KeyBoardEvents() detiene la aplicación, pero pierdo el control con el ratón y me gustaría en la función KeyBoardEvents() asignarle al ENTER que funcionará como el TAB, Saludos



#include "FiveTouch.ch"

function Main()

local oDlg, oGet1, cTest
local oBtnOk, oBtnCancel

DEFINE DIALOG oDlg

@ 20, 20 GET oGet1 VAR cTest OF oDlg SIZE 100, 20

oGet1:connect( QEvent_KeyPress , { |e| KeyBoardEvents( e, cTest ) } )
//QEvent_KeyPress -- viene de Hbqtgui.ch

@ 200, 90 BUTTON oBtnOk PROMPT "Ok" OF oDlg ;
ACTION MsgInfo( "Ok!" )

@ 200, 220 BUTTON oBtnCancel PROMPT "Cancel" OF oDlg ;
ACTION oDlg:End()

ACTIVATE DIALOG oDlg CENTERED

return nil
//---------------------------------------------------
Function KeyBoardEvents( e, cText )
LOCAL lSalida := .T.
LOCAL nKey := e:key()

// (.T.) No Permite Continuar
// (.F.) Permite Continuar

Do Case
Case nKey == Qt_Key_Return .OR. nKey == Qt_Key_Enter
MsgInfo('Enter')
lSalida := .F.

Case nKey == Qt_Key_Tab
MsgInfo('Tab')
lSalida := .F.

Case nKey == Qt_XButton1
MsgInfo('Mouse')
lSalida := .F.

Case nKey == Qt_Key_F1
MsgInfo('F1')
lSalida := .T.

EndCase

Return( lSalida )
jtscalpe
 
Posts: 18
Joined: Thu Sep 07, 2017 6:20 pm


Return to FiveTouch

Who is online

Users browsing this forum: No registered users and 2 guests