why setFocus does not set the focus when called on an attending pushbutton?
-
@jdent said in why setFocus does not set the focus when called on an attending pushbutton?:
But my tableView can accept focus: if I click on a row it is selected !!
So far as I know, clicking a row is not focus. Why do you assume it is? Focus is for where input goes. If you want to select a row, look for
select
notfocus
in table view docs. -
@jdent maybe it cannot work because I am pressing a button and releasing will call setfocus() on the button...
interrupting the chain of messages!!In MFC programming in Windows there was the concept of PostMessage() instead of SendMessage() and it was ideal for things like this. The setFocus() is like a SendMessage() but I need it to be posted in the queue of events and handled after control returns from presssing the button!! Is there nothing like this in Qt??
-
@jdent
It is possible the pushbutton click is interfering, but I wouldn't assume so. Put yourtableview->setFocus()
as the action on aQTimer::singleShot()
with a delay of 0 to test that. Like (untested):QTimer::singleShot(0, this, [this]() { tableView->setFocus(); } );
It is also possible that your tableview does not accept focus? If you make your model read-only per your other thread, I don't think it will accept focus?
-
@jdent said in why setFocus does not set the focus when called on an attending pushbutton?:
But my tableView can accept focus: if I click on a row it is selected !!
So far as I know, clicking a row is not focus. Why do you assume it is? Focus is for where input goes. If you want to select a row, look for
select
notfocus
in table view docs. -