GotFocus

Coding + IDE + Code-Editor + Syntax + User-Functions + Anything else

GotFocus

Postby Henning » Fri Apr 13, 2012 9:12 pm

Hi,

I've now tried all the ways I know of to trigger a QLineEdit GotFocus (Event/Signal). HOW???
Most tries don't throw any errors, just don't trigger...

/Henning
Henning
 
Posts: 523
Joined: Fri Aug 13, 2010 6:29 pm

Re: GotFocus

Postby Slowdown » Sat Apr 14, 2012 6:37 pm

Hi Henning,

Code: Select all
Outlet lineEdit As QLineEdit
Dim DoesHaveItFocus As Boolean

  SetFocus(lineEdit)' setfocus to Qwidget
  DoesHaveItFocus = lineEdit.focus' does have QWidget has focus

Is this what you need ?
Found no Signal or Event.
Kind regards,
Slowdown

OSX 10.8.x, VBox Xp, Ubuntu 32/64 bit, EOS 64 bit
Slowdown
 
Posts: 465
Joined: Sat May 01, 2010 7:11 pm
Location: Netherlands

Re: GotFocus

Postby Henning » Sat Apr 14, 2012 9:50 pm

Hi,

Thanx for researching but, yes I need a Signal or an Event.

When the LineEdit is selected (Mouse/Tab/SetFocus) I need to change the background color to highlight which LineEdit control has focus.

I also need it for LostFocus when another control gets Focus, to restore the unselected background color.

/Henning
Henning
 
Posts: 523
Joined: Fri Aug 13, 2010 6:29 pm

Re: GotFocus

Postby Slowdown » Sun Apr 15, 2012 5:49 am

Hi,
The only Signal you perhaps can use is,
Code: Select all
Signal on_lineEdit_editingFinished()
  Print "Finished"
End Signal

This is triggered when QLineEdit has lost it's focus (Tab or clicked an other control).
Kind regards,
Slowdown

OSX 10.8.x, VBox Xp, Ubuntu 32/64 bit, EOS 64 bit
Slowdown
 
Posts: 465
Joined: Sat May 01, 2010 7:11 pm
Location: Netherlands

Re: GotFocus

Postby berndnoetscher » Mon Apr 16, 2012 8:06 am

Hi Henning

The following code shows how to do this. Unfortunetaly, there is a regression bug (I accidently changed a few lines of code in the compiler related to the set feature), so it won't work unless you download the newest release, which I will upload right now.

The trick is to use Qt Designer and create QLineEdit, but actually "extend" the QLineEdit to a q7b control "TextBox", which have signals for lostfocus etc. (see the documentation).
QLineEdit has no lost/gotfocus signal native (the Qt way would be to create a sub class of QLineEdit and use this, therefore I provide the "TextBox")

Code: Select all
Outlet lineEdit1 As QLineEdit Set TextBox ' add TextBox feature to the QLineEdit (actually TextBox is a sub class of QLineEdit)

Signal on_lineEdit1_GotFocus()
  lineEdit1.setStyleSheet("background-color: rgb(255, 0, 0);")
End Signal

Signal on_lineEdit1_LostFocus()
  lineEdit1.setStyleSheet("background-color: rgb(255, 255, 255);")
End Signal
berndnoetscher
Site Admin
 
Posts: 344
Joined: Thu Mar 25, 2010 9:57 am

Re: GotFocus

Postby berndnoetscher » Mon Apr 16, 2012 8:19 am

Hi Henning,

you reported the docuemtation browser of Qt Designer shipped with q7b does not work (assistant.exe). I tried to integrate it, but I did not succeeded and don't know how to do it. It complained about a missing file, which I could not find in the Qt installation (qthelpcollection...). A workaround is to install Qt for yourself or to use the documentation links for Qt Designer and Qt within the q7b IDE.
berndnoetscher
Site Admin
 
Posts: 344
Joined: Thu Mar 25, 2010 9:57 am

Re: GotFocus

Postby Henning » Mon Apr 16, 2012 9:08 am

Hi Bernd,

I will try the "new" compiler and test the Q7b TextBox feature.

The installation of the Qt libraries takes care of the Assistant help in Designer, so there is no request from me to include it in Q7b.

Thx for the fast response. :)

/Henning
Henning
 
Posts: 523
Joined: Fri Aug 13, 2010 6:29 pm

Re: GotFocus

Postby Henning » Mon Apr 16, 2012 10:50 pm

Hi Bernd,

Tried the new Q7b, but OnFocus doesn't trigger...

Code: Select all
Public Outlet txtTLVS_ID As QLineEdit Set TextBox

Signal on_txtTLVS_ID_GotFocus()
  txtTLVS_ID.setStyleSheet("background-color: rgb(100, 255, 255)")
  MsgBox("frm_Config", "txtTLVS_ID SetFocus")
End Signal


/Henning
Henning
 
Posts: 523
Joined: Fri Aug 13, 2010 6:29 pm

Re: GotFocus

Postby berndnoetscher » Tue Apr 17, 2012 7:34 am

Henning wrote:Hi Bernd,

Tried the new Q7b, but OnFocus doesn't trigger...

Code: Select all
Public Outlet txtTLVS_ID As QLineEdit Set TextBox

Signal on_txtTLVS_ID_GotFocus()
  txtTLVS_ID.setStyleSheet("background-color: rgb(100, 255, 255)")
  MsgBox("frm_Config", "txtTLVS_ID SetFocus")
End Signal


/Henning


Curious, it works with the latest release on my PC. Just tested it again.

Q7BCompiler.exe must have date 16-April-2012
Did you clean & rebuild?
berndnoetscher
Site Admin
 
Posts: 344
Joined: Thu Mar 25, 2010 9:57 am

Re: GotFocus

Postby Henning » Tue Apr 17, 2012 1:12 pm

Yes I did, now I've deleted and reinstalled latest version again, and same thing. No trig on OnFocus.

Can there be a difference in that I have my QLineEdit boxes on QFrames and QStackedWidgets?

Another mystery:
I have a pile of QStackedWidgets, to compile I need: Public Declare Sub "QStackedWidget" void setCurrentIndex(int index);
And access with for example: frUnitSettings.setCurrentIndex(frTCU)
frUnitSettings is: Public Outlet frUnitSettings As QStackedWidget
frTCU is an Integer Value, in this case = 0
If I comment the Declare it stops compiling without any error msg.

I find it confusing to know when I need to Declare a function or not, and when to use ctrl.fn(Value) or ctrl!fn = Value
In class2.txt I find: QStackedWidget:Property:CurrentIndex::Integer
?????

/Henning
Henning
 
Posts: 523
Joined: Fri Aug 13, 2010 6:29 pm

Next

Return to Questions & Answers

Who is online

Users browsing this forum: No registered users and 1 guest

cron