Results 1 to 4 of 4

Thread: How to set focus on control

  1. #1

    Default How to set focus on control

    I have a class derived from QVBoxLayout and it has several controls derived from QWidget. When I press cursor arrows focus switches from control to control correctly. But when I try to set focus with QWidget::setFocus() nothing happens. Focus stays on previous control. Question is how to set focus on needed control grammatically?
    Thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to set focus on control

    Can you show some relevant code?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3

    Default Re: How to set focus on control

    Unfortunately no... It's a huge project that I need to fix and now I am trying to understand how it works.

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to set focus on control

    Try setting the focus on the first widget BEFORE you show the window in which the widgets are in.
    See if setFocus() works then.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. Replies: 2
    Last Post: 8th October 2010, 07:03
  2. Replies: 0
    Last Post: 16th December 2009, 09:45
  3. Window focus issues (How to force focus to a window?)
    By montylee in forum Qt Programming
    Replies: 3
    Last Post: 25th April 2009, 01:00
  4. UIC eol control
    By Max Yaffe in forum Qt Tools
    Replies: 0
    Last Post: 13th July 2007, 20:25
  5. Focus issues / Setting multiple focus
    By ComputerPhreak in forum Qt Programming
    Replies: 1
    Last Post: 16th February 2007, 06:09

Tags for this Thread

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.