Results 1 to 4 of 4

Thread: how to set focus on widget if it is selected??

  1. #1
    Join Date
    Oct 2009
    Posts
    105
    Thanked 4 Times in 2 Posts
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default how to set focus on widget if it is selected??

    Hi All,
    I've created some small window ( derived from Qwidget), and place it in top of another QWidget. My requirment is ,If i select any small window then it should be focused and border need to be green. I override the paintevent(0 methode and did like following.

    Qt Code:
    1. this->setStyleSheet("border: 2px solid Red");
    2. this->setFocus();
    To copy to clipboard, switch view to plain text mode 

    But its not working? Can any bold tell me how to achive this.?

    Thank u all.

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to set focus on widget if it is selected??

    Donot set style sheet in painEvent .

    You only need to set the stylesheet initially.
    Qt Code:
    1. QWidget:focus {
    2. border: 3px solid green;
    3. }
    To copy to clipboard, switch view to plain text mode 

    But if you use stylesheet, you will need to set its background and other things too. It simply wont draw border on top of the widget.

  3. #3
    Join Date
    Oct 2009
    Posts
    105
    Thanked 4 Times in 2 Posts
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: how to set focus on widget if it is selected??

    Quote Originally Posted by aamer4yu View Post
    Donot set style sheet in painEvent .

    You only need to set the stylesheet initially.
    Qt Code:
    1. QWidget:focus {
    2. border: 3px solid green;
    3. }
    To copy to clipboard, switch view to plain text mode 

    But if you use stylesheet, you will need to set its background and other things too. It simply wont draw border on top of the widget.
    HI i set the style sheet in c'tor. still its not changing the border. Ny other way to focus on a widget if it selected as in above descriptiuon?????

  4. #4
    Join Date
    Oct 2009
    Posts
    105
    Thanked 4 Times in 2 Posts
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: how to set focus on widget if it is selected??

    Hi All.
    Till nw i'm not stick with this problem. Plz help.

Similar Threads

  1. widget focus question
    By eva2002 in forum Newbie
    Replies: 1
    Last Post: 12th January 2010, 00:04
  2. widget focus ---------
    By jrodway in forum Qt Programming
    Replies: 11
    Last Post: 27th April 2009, 09:16
  3. Widget Focus
    By navi1084 in forum Qt Programming
    Replies: 6
    Last Post: 29th September 2008, 10:22
  4. How to display selected columns in QTableView widget.
    By kaushal_gaurav in forum Qt Programming
    Replies: 2
    Last Post: 8th August 2008, 08:30
  5. Customize on focus widget
    By vql in forum Qt Programming
    Replies: 9
    Last Post: 9th April 2008, 18:58

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.