Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[Solved] Including Demo Browser into own GUI / Demoapp



  • Hi

    I have a small GUI / Demoapp from which I want to start the webbrowser located in \demos\browser, among various other things.
    How do I best include this to start the browser from a Button in my GUI and returning to my GUI when the browser is closed?

    Thanks
    Franz



  • Do you make GUI in QML or in plain Qt?



  • [quote author="McLion" date="1349715693"]
    How do I best include this to start the browser from a Button in my GUI and returning to my GUI when the browser is closed?
    [/quote]

    In my opinion you should consider the option to embed a "QWebView":http://qt-project.org/doc/qt-4.8/qwebview.html at your application. Check out "this simple example to learn how to embed a webview and to open a web page":http://qt-project.org/wiki/Open_Web_Page_in_QWebView.



  • Thank you guys.

    @guziemic
    Plain Qt (Widget in Designer) because I am currently bound to 4.6.3 on embLinux which does not feature most of the QML stuff ... too bad.

    @leon.anavi
    Your're probably right, for the final product for which I will do it this way to be able to design all the features like I want to have.
    However, I need to have demo version right now (like in immediately) which simply has to show that browsing to some predefined bookmarks is possible.
    Since I am unexperienced in Qt I feel like the fastest way is to simply include the finished browser.



  • [quote author="McLion" date="1349765748"]Since I am unexperienced in Qt I feel like the fastest way is to simply include the finished browser.
    [/quote]

    OK, check the documentation "QDesktopServices":http://qt-project.org/doc/qt-4.8/QDesktopServices.html You can open an external browser using "openUrl":http://qt-project.org/doc/qt-4.8/qdesktopservices.html#openUrl



  • There is no external browser. I am developing for an embedded device (STB chip). So, I need to include it in Qt. There is a driver base which links Qt via DFB to the native HW graphic layer. There is no way to run standard apps.



  • If you do not want to include QWebView you could also with use of "QProcess":http://doc.qt.digia.com/qt/qprocess.html#start start another application (Browser).



  • Can I keep track of the started Browser (do I get its PID for instance) and also terminate it from my GUI. This way I could maybe start the compiled Qt Demo browser as external browser, but I need to be able to have it killed from my overlay GUI.



  • Yes, you can have information about PID.

    For instance you you start process as "detached process":http://doc.qt.digia.com/qt/qprocess.html#startDetached then you will have it from method arguments.

    But in case of some problems in GUI, stand alone process will remain.

    In case of just simple start all processes are connected and exception in one -> causes killing whole application. But to have PID - probably you can use "QProcess:pid()":http://doc.qt.digia.com/qt/qprocess.html#pid

    Actually I was using approach with startDetached to run several application from my main GUI application.



  • Thanks

    I'll try the detached process because QProcess:pid() will probably return the GUI's pid and not the one of the started browser so I will still lack a way to terminate it.



  • Then to kill process you can call something like this

    @
    QProcess killer;
    QString command = QString("kill %1").arg(pid);
    killer.start(command);
    killer.waitForFinished();
    @

    Anyway, if your problem is solved please add [solved] to post topic.



  • OK .. testing

    Could somebody tell me what is wrong with:
    @process.startDetached("browser","-qws -display directfb --dfb:mode=1280x800","/opt/bin/", browserPID);@
    Compiler tells me: no matching function for call to 'QProcess::startDetached(const char [8], const char [43], const char [10], Q_PID&)'



  • Found a solution:

    Starting with:
    @process.start("/opt/bin/browser -qws -display directfb --dfb:mode=1280x800");@

    Terminating with:
    @process.terminate();@


Log in to reply