Problem when switching between forms in QML
Hi everybody,
In my Qt project, i use QML for design my GUI. My program have a mainform and a number of .qml GUI file. When i want to show a QML form, i link the mainform.cpp --> to the .QML GUI file respectively.
here is my code
formmain.h
Code:
Q_INVOKABLE void configuration() { displayForm("qrc:/UI/frmconfiguration.qml");}
Q_INVOKABLE void mainScreen() { displayForm("qrc:/UI/frmmain.qml");}
{
QDeclarativeView* pView = loadForm(qmlFile);
setCentralWidget(pView);
pView->setFocus();
}
formain.cpp
Code:
QDeclarativeView
* FrmMain
::loadForm(QString qmlFile
){
QDeclarativeView
* pDeclarative
= new QDeclarativeView
(QUrl(qmlFile
));
pDeclarative->setResizeMode(QDeclarativeView::SizeRootObjectToView);
pDeclarative->rootContext()->setContextProperty("navigator",this);
return pDeclarative;
}
in the .QML GUI form, when an event buttonpressed occur, the navigator is called. For example when i'm in formmain and button Configuration is pressed, something like below is carry out :
Code:
Keys.onEnterPressed : navigator.frmconfiguration()
But the problem here is : when i press button Configuration and switch to new Configuration GUI form, the system doesn't focus to this new form unless i use mouse to click on this new form ( Configuration Form )
This bug is very critical for my project , so could anybody help me fix this bug :( i'm very respected for your help :(:(
sincerely