View Full Version : Problem when switching between forms in QML

24th November 2011, 02:52
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


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);


QDeclarativeView* FrmMain::loadForm(QString qmlFile)
QDeclarativeView* pDeclarative = new QDeclarativeView(QUrl(qmlFile));
pDeclarative->setResizeMode(QDeclarativeView::SizeRootObjectToVi ew);
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 :

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 :(:(