hasFocus() ??
Unsolved
General and Desktop
-
@Duy-Khang said in hasFocus() ??:
but it does'n work .
Well, I would imagine it does work, else others would complain?! How does your situation compare to, say, https://stackoverflow.com/questions/46702487/how-can-i-get-current-focused-qlineedit-in-qt ?
-
@JonB said in hasFocus() ??:
Well, I would imagine it does work, else others would complain?! How does your situation compare to, say
not like that. suppuse :
ui->lineEdit_username->setFocus();
if(ui->lineEdit_username->hasFocus())
{
ui->lineEdit_username->setStyleSheet("color : red"); // it still doesn't work ?
} -
Hi
Useing code to check for fucus will work poorly if used in constructor and code must be run every time
focus shifts so it's easier to do with stylesheet alone.QLineEdit:focus { color:red; }