PDA

View Full Version : Focus problem



waynew
1st May 2010, 00:15
This should be simple, but I can't get it to work right.
I have two display objects for some database data, one a table view and one a dialog.
The table view shows multiple records and the dialog shows a single record view.
Depending on saved preferences, one or the other opens on application start up.
If the table view opens, the focus returns to the main window. If the dialog opens, the focus stays on the dialog, not the main window. The dialog is non-modal.
There is a pushbutton on the main window to switch between the two displays.
If you switch to the table view, the focus returns to the main window, if you switch to the dialog, the focus stays on the dialog. I have added the following code both on application start up and on display switching to try and force the focus back to the main window after the dialog opens, but it isn't doing it.

Any suggestions?



MainWindow::close();
MainWindow::show();

SixDegrees
1st May 2010, 00:38
QWidget-setFocus( (http://doc.qt.nokia.com/4.5/qwidget.html#setFocus)) may be of help.

Have a look at QWidget->activateWindow() (http://doc.qt.nokia.com/4.5/qwidget.html#activateWindow), too.

waynew
1st May 2010, 00:42
Thanks, but I forgot to mention that I tried setting the focus to a widget in the main window - unfortunately, to no effect.

SixDegrees
1st May 2010, 01:02
Thanks, but I forgot to mention that I tried setting the focus to a widget in the main window - unfortunately, to no effect.

Yeah. I think activateWindow() might be a better bet.

I'm assuming you can manually activate the main window by clicking on it. If not, there may be a modeless/modal issue with your dialog.

waynew
1st May 2010, 02:24
Tried that, no luck. Same problem.