Re: Tab/Enter focus problem
Try adding these lines to where you show the "form B":
Code:
formB->show(); // you have already this
formB->raise(); // <--- add this
formB->activateWindow(); // <--- and this
Re: Tab/Enter focus problem
Thanks for the reply JPN.
Unfortunately it didn't work. I have posted the code for the function below.
This is the call to open formB.
Thanks, b1.
Code:
void BackOrderForm::checkMainDatabase()
{
if (!lineEdit->text().isEmpty())
{
temppartnumber = lineEdit->text();
checkmaindqry.prepare( "SELECT description, brand FROM dbparts WHERE boffinspartno=(\'"+temppartnumber+"\')" );
checkmaindqry.exec();
checkmaindqry.next();
if (checkmaindqry.isValid())
{
lineEdit_2->setText(checkmaindqry.value(0).toString());
lineEdit_6->setText(checkmaindqry.value(1).toString());
}
else
{
TempNewPart = lineEdit->text();
formB = new UIDisplayPart::UIDisplayPart;
connect( formB->okButton, SIGNAL( clicked() ), this, SLOT( updateText() ) );
formB->show();
formB->raise();
formB->activateWindow();
formB->lineEdit_2->setFocus();
}
TempNewPart = "";
}
}
Re: Tab/Enter focus problem
Quote:
Originally Posted by
b1
formB = new UIDisplayPart::UIDisplayPart;
...
formB->show();
formB->raise();
formB->activateWindow();
QWidget::activateWindow() won't work for windows that aren't shown and new windows are shown after the control goes back to the event loop.
This might work:
Code:
void BackOrderForm::activateFormB()
{
formB->activateWindow();
}
...
QTimer::singleShot( 0,
this,
SLOT( activateFormB
() ) );
// or if you don't like timers:
// QMetaObject::invokeMethod( this, "activateFormB", Qt::QueuedConnection );
Another solution you can try is:
Code:
formB->show();
formB->raise();
QApplication::processEvents();
// or QApplication::processEvents( QEventLoop::ExcludeUserInputEvents ); formB->activateWindow();
Re: Tab/Enter focus problem
Thanks for the reply, jacek.
I tried all combinations of your suggestions and none work. I will go back to the drawing board and try recoding it all another way.
Thanks for the help so far, b1.