Results 1 to 6 of 6

Thread: QLineEdit and focusInEvent

  1. #1
    Join Date
    Aug 2007
    Posts
    5
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default QLineEdit and focusInEvent

    I want to be able to handle when a QLineEdit control receives focus. I've been looking through the documentation for QLineEdit and it sounds like I will have to subclass QLineEdit and reimplement focusInEvent.

    This doesn't sound too difficult (although if anyone has any sample code that would be great), but how do I get this new subclassed control to show up in designer? Do I really have to create a designer plug-in? Is there an easier way to do this to handle focus signals/events?

    Thanks!

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QLineEdit and focusInEvent

    Well, the idea is that you won't need designer now.
    You create everything in code, all the widgets, starting with the dialog(by subclassing QDialog).

    I think the easiest is to look at one of the Qt exmples.
    Like QHttp , since it has a really simple interface( a line edit, and a few buttons).
    You could easily replace that label with your custom one.

    Generally, the Qt demos are a good source of information.

    Regards

  3. #3
    Join Date
    Aug 2007
    Posts
    5
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Re: QLineEdit and focusInEvent

    This would be an acceptable solution if I only had 1 or 2 QLineEdits which I needed this for but unfortuanatly I have about 15-20 of them. I really don't want to write instantiation and positioning code for all of them. I really prefer to have that stuff handled by the generated code if at all possible.

    Also I didn't see a QHttp example in the examples directory. Where would I find this?

    Thanks!

  4. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QLineEdit and focusInEvent

    This would be an acceptable solution if I only had 1 or 2 QLineEdits which I needed this for but unfortuanatly I have about 15-20 of them. I really don't want to write instantiation and positioning code for all of them. I really prefer to have that stuff handled by the generated code if at all possible.
    Well then create 20 line edits in designer and promote them to your custom class( right click, promote to... etc).

    Also I didn't see a QHttp example in the examples directory. Where would I find this?
    It is in the Networking folder.

    Regards

  5. The following user says thank you to marcel for this useful post:

    fuzzywuzzy01 (14th August 2007)

  6. #5
    Join Date
    Aug 2007
    Posts
    5
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Re: QLineEdit and focusInEvent

    Is there an equivalent way of doing that in Qt3? I'm in the process to porting to Qt4 but I'm not quite there yet.

    Thanks for all the help by the way!

  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 975 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QLineEdit and focusInEvent

    Quote Originally Posted by fuzzywuzzy01 View Post
    Is there an equivalent way of doing that in Qt3? I'm in the process to porting to Qt4 but I'm not quite there yet.
    The promotion mechanism isn't available in Qt3, so you will have to write a plugin for desginer. But maybe you don't have to subclass QLineEdit? Have you tried installing an event filter on those line edits?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.