Results 1 to 6 of 6

Thread: QWebView with two instances of QApplication

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: QWebView with two instances of QApplication

    QApplication (QCoreApplication) is a singleton design, it is not intended to be created multiple times in an application. As a matter of fact even if you create multiple instance, user code will access a different instance (may be the second instance) and the Qt library code will still be using the first instance and if you deleted the first instance or has gone out of scope your system will be UNSTABLE.

    You have to consider to change the test approach and base all you testing with one QApplication instance.

    Even if some one were to find the reason behind the behavior (the obvious reason is that Qt lib internally uses the first instance), you will still have to live with single QApplication instance.

    It would also help to know, if someone can try this on Mac or Unix, if this happens on another platfom/compiler combination.
    I think it is clear that platform will not play any role in this, it is just that Qt is designed that way.
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  2. The following user says thank you to Santosh Reddy for this useful post:

    khilin (25th April 2013)

  3. #2
    Join Date
    Apr 2013
    Posts
    2
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QWebView with two instances of QApplication

    Santosh, thank you very much for your answer.

    After we read your answer we are already working to change the test approach to use only one instance of QApplication. We have a question about it, is there any way to reset the state of the instance of QApplication, we want to be sure that the execution of one test does not affect the execution of the rest of the tests.

    Again, thank you for your time.

    Daniel

  4. #3
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: QWebView with two instances of QApplication

    We have a question about it, is there any way to reset the state of the instance of QApplication,
    As such there is no direct way (API) to reset the QApplication. What you could do is individually reset the properties which are of your interest.

    we want to be sure that the execution of one test does not affect the execution of the rest of the tests.
    IMO, when it come to unit tests, each test is supposed to set up it's required settings with in the test itself, so the test case should pass what ever be the condition of QApplication, so I don't see any need to resetting QApplication state
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QWebView with two instances of QApplication

    What exactly would you want to reset in the application object? If you are not modifying the object yourself then there is nothing to reset. Webviews will not contaminate the application object in any way.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #5
    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: QWebView with two instances of QApplication

    I would suggest to look into Qt's unit test framework QTestLib.

    It is trivial to use and you'll get a separate executable for all things you want to have separate.

    Cheers,
    _

Similar Threads

  1. Multiple instances of QWebView
    By darious in forum Qt Programming
    Replies: 1
    Last Post: 11th October 2011, 07:55
  2. Replies: 2
    Last Post: 1st August 2011, 06:30
  3. Chaining QIODevice Instances
    By wswartzendruber in forum Newbie
    Replies: 9
    Last Post: 29th July 2009, 20:23
  4. Multiple program instances
    By scwizard in forum Qt Programming
    Replies: 13
    Last Post: 1st April 2007, 17:42
  5. accessing my own class-instances
    By mikro in forum Newbie
    Replies: 3
    Last Post: 11th July 2006, 00:10

Tags for this Thread

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.