PDA

View Full Version : how to set focus on widget if it is selected??



sudhansu
27th January 2010, 07:08
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.


this->setStyleSheet("border: 2px solid Red");
this->setFocus();

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

Thank u all.

aamer4yu
27th January 2010, 08:07
Donot set style sheet in painEvent .

You only need to set the stylesheet initially.


QWidget:focus {
border: 3px solid green;
}


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.

sudhansu
28th January 2010, 11:22
Donot set style sheet in painEvent .

You only need to set the stylesheet initially.


QWidget:focus {
border: 3px solid green;
}


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?????

sudhansu
30th January 2010, 07:42
Hi All.
Till nw i'm not stick with this problem. Plz help.