Results 1 to 2 of 2

Thread: setFocus() on Lineedit

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2009
    Posts
    20
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default setFocus() on Lineedit

    Hi

    I have a QTableWidget , over which when the user presses an alphabet , a QDialog opens. The QDialog contains a lineedit .The user entered text is carried over to the lineedit but the tablewidget item remains highlighted.

    I would like the focus to be set on the next lineedit in the second cursor position.

    I have tried using setfocuspolicy(QT::Strongfocus) on the lineedit and also call the setfocus().But it does not help. The only solution that works is using activatewindow().However this has a downside, when i switch to different application without clicking outside in my current application, the dialog remains in the forefront.

    Is there a better way than using activatewindow(), or how can i detect that a different application is now active and close the dialog (given that the user does not click outside)

    Thankyou

  2. #2
    Join Date
    Dec 2009
    Posts
    29
    Thanks
    2
    Thanked 3 Times in 3 Posts

    Default Re: setFocus() on Lineedit

    just do:

    QWidget->close();
    QWidget->Show();


    works for me.

  3. The following user says thank you to yodasoda for this useful post:

    waynew (24th April 2010)

Similar Threads

  1. Replies: 3
    Last Post: 26th August 2009, 06:44
  2. setFocus problem
    By roxton in forum Qt Programming
    Replies: 3
    Last Post: 12th February 2009, 05:41
  3. SetFocus/Actiwation widget
    By visor_ua in forum Qt Programming
    Replies: 0
    Last Post: 29th October 2008, 14:04
  4. QLineEdit setFocus
    By bunjee in forum Qt Programming
    Replies: 4
    Last Post: 24th April 2008, 16:22
  5. setfocus working?
    By mahe2310 in forum Qt Programming
    Replies: 8
    Last Post: 10th March 2006, 02:45

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
  •  
Qt is a trademark of The Qt Company.