Search code examples
qt4fullscreenqml

Full-screen desktop application with QML


I have experience with developing rich user interface application with flex and AS3. However the issue is its very hard to use existing c++ business logic with these flex apps. With the advent of QML, I am curious whether its possible to reuse the c++ business logic with QT for rich UI apps.

I want to know whether its possible to develop full screen rich user interface applications(which are becoming more and more common especially in mobile devices) for the desktop. For example(http://blog.flexexamples.com/2007/08/07/creating-full-screen-flex-applications/) Adobe has the Flash Player which can be used in full screen mode and runs content written in AS3. Is it possible to write similar applications using QT/QML?


Solution

  • If you would like to use business logic written on C++ and some QML user interface you can use QDeclarativeView inside your application. It's just a regular Qt widget so it has method showFullScreen(). Actually this class is like "qmlviewer inside your application".

    So you'll get something like this:

    #include <QtGui/QApplication>
    #include <QtDeclarative/QDeclarativeView>
    #include <QtCore/QUrl>
    
    int main(int _argc, char * _argv[])
    {
        QApplication app(_argc, _argv);
    
        QDeclarativeView view;
        view.setSource(QUrl("qrc:/MyGui.qml"));    // if your QML files are inside 
                                                   // application resources
    
        view.showFullScreen();    // here we show our view in fullscreen
    
        return app.exec();
    }
    

    You can find more information here.