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
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();
}
Q_INVOKABLE void configuration() { displayForm("qrc:/UI/frmconfiguration.qml");}
Q_INVOKABLE void mainScreen() { displayForm("qrc:/UI/frmmain.qml");}
void displayForm(QString qmlFile)
{
QDeclarativeView* pView = loadForm(qmlFile);
setCentralWidget(pView);
pView->setFocus();
}
To copy to clipboard, switch view to plain text mode
formain.cpp
QDeclarativeView
* FrmMain
::loadForm(QString qmlFile
){
QDeclarativeView
* pDeclarative
= new QDeclarativeView
(QUrl(qmlFile
));
pDeclarative->setResizeMode(QDeclarativeView::SizeRootObjectToView);
pDeclarative->rootContext()->setContextProperty("navigator",this);
return pDeclarative;
}
QDeclarativeView* FrmMain::loadForm(QString qmlFile)
{
QDeclarativeView* pDeclarative = new QDeclarativeView(QUrl(qmlFile));
pDeclarative->setResizeMode(QDeclarativeView::SizeRootObjectToView);
pDeclarative->rootContext()->setContextProperty("navigator",this);
return pDeclarative;
}
To copy to clipboard, switch view to plain text mode
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 :
Keys.onEnterPressed : navigator.frmconfiguration()
Keys.onEnterPressed : navigator.frmconfiguration()
To copy to clipboard, switch view to plain text mode
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
Bookmarks