Results 1 to 5 of 5

Thread: Run a synchronous Browser

  1. #1
    Join Date
    Jan 2015
    Posts
    3
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Run a synchronous Browser

    Hello all,
    I have the following problem :
    I need to open URLs using a new window of the default browser of the OS. However, the HMI shall inhibit some user actions until the opened browser page is closed.

    I tried things but still could not find any good solution :
    - openUrl() method perfectly answer to the first part of my problem but it is not synchronous.
    - I tried to start the browser using QProcess :
    * I did not found a way to acquire the default OS browser at the runtime. Thus, I created a configuration file for my application which contains the exe paths of the browsers for all systems. This solution is good enough for me but I am open to any suggestions...
    * I launch the URLs using QProcess::start(). However, I have different behaviors depending on the meteorite falls on Mars :
    -> Windows, IExplorer : It seems to behave like I want.
    -> Linux/Windows, Firefox : I have to deal with another problem : firefox cannot be easily launch in a new separate process. Thus, if the browser is not initially launched, the solution works. If firefox is already launched, QProcess exit immediately.

    I am using Qt5 and my soft is executed on Linux and Windows.

    Did anyone face this general problem of launching a synchronous browser?

    I am sorry if my english is full of mistakes. I tried my best

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Run a synchronous Browser

    I don't think there is any generic solution on the process level since there are way to many browsers with different behaviors.

    You could try the -new-instance option for Firefox, but of course that will only work for Firefox.

    Can I ask why you need that?
    Why is it important that the browser window has been closed?

    Cheers,
    _

  3. #3
    Join Date
    Jan 2015
    Posts
    3
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Run a synchronous Browser

    In fact, I missed the '-new-instance' option.
    This curious option is not documented (https://developer.mozilla.org/en-US/...d_Line_Options) and it doesn't seems to work... :
    - <firefox -new-instance www.google.com> doesn't start a new process; it only launch the URL in a new window. The effect of -new-instance seems to be close to -new-window.
    - This option doesn't "freeze" QProcess::start() : The firefox window is launched and I immediately receive the finish signal.

    For sure you may ask The client (i.e. god) wants to launch a sequence of jobs with the guaranty that only 1 job will be running at the time. Jobs may be scripts, distant commands, etc. or URLs (on Intranets or whatever...)

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Run a synchronous Browser

    Well, you would have best control obviously when not delegating to an external browser.

    One idea for using an external browser could be to make the browser talk to the application.
    Something like opening a listening socket with the app and let the browser open an URL that connects to this instead. The deliver some HTML that embeds the actual remote content but also keeps the connection open as long as the page/tab is open.

    Cheers,
    _

  5. #5
    Join Date
    Jan 2015
    Posts
    3
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Run a synchronous Browser

    I will discuss your solution with my colleagues and god.
    Thank you for your help. I will keep you informed about the choosen solution.

Similar Threads

  1. run example qt5.1.1 browser on arm (qt-5.1.1/examples/webkitwidgets/browser/browser)
    By soumya pandiyattu in forum Qt for Embedded and Mobile
    Replies: 3
    Last Post: 8th December 2014, 07:47
  2. Implementing synchronous mechanism
    By Vagesh in forum Qt Programming
    Replies: 11
    Last Post: 27th November 2014, 07:50
  3. Replies: 0
    Last Post: 17th March 2011, 03:17
  4. Not able to run fancy browser and demo browser example applications
    By GoGetIt in forum Installation and Deployment
    Replies: 1
    Last Post: 16th August 2010, 06:23
  5. Synchronous QFtp?
    By aarpon in forum Qt Programming
    Replies: 2
    Last Post: 26th October 2009, 09:28

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.