Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt WebKit
  4. Calling Qapplication.exec multiple times in loop is possible, if yes how?
Forum Updated to NodeBB v4.3 + New Features

Calling Qapplication.exec multiple times in loop is possible, if yes how?

Scheduled Pinned Locked Moved Qt WebKit
4 Posts 3 Posters 4.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    anjna
    wrote on last edited by
    #1

    Calling the Qapplication.exec in a loop is not giving proper results. can you give the other way to do the same.

    @
    public static void main(String args[]) {
    QNetworkProxy proxy = new QNetworkProxy(ProxyType.HttpProxy,"web-proxy.sgp.hp.com", 8080);
    QNetworkProxy.setApplicationProxy(proxy);
    for(int i=0; i<2;i++){
    QApplication.initialize(args);
    HelloWebKit widget = new HelloWebKit();
    widget.show();

        QApplication.exec&#40;&#41;;
    

    }
    }
    @

    [formated the code properly, Tobias]

    1 Reply Last reply
    0
    • L Offline
      L Offline
      lgeyer
      wrote on last edited by
      #2

      QApplication::exec() enters the event loop and does not return unless QApplication::exit() is called or if the event loop is already running.

      I'm not a Qt for Java expert but I assume the QApplication object has to be initialized once and QApplication::exec() has to be called just once too - as in C++. If you want two widgets just create two widgets. What is the purpose of the loop?

      @
      public static void main(String[] args)
      {
      QApplication.initialize(args);

      QNetworkProxy proxy = new QNetworkProxy(ProxyType.HttpProxy,
                                              "web-proxy.sgp.hp.com",
                                              8080);
      QNetworkProxy.setApplicationProxy(proxy);
      
      HelloWebKit widgetA = new HelloWebKit();
      widgetA.show();
      
      HelloWebKit widgetB = new HelloWebKit();
      widgetB.show();
      
      QApplication.exec&#40;&#41;;
      

      }
      @
      Brain to terminal. Not tested. Exemplary.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #3

        QApplication can only be started with exec() once. Not multiple times in a loop. If you really need separate event loops, you can using QEventLoop, but I really, really doubt you need that.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          anjna
          wrote on last edited by
          #4

          Actually I am not using the simple for loop. I have a simple dynamic java project in which i have included the webkit project as a jar, which renders the html page.
          So when the request comes to the servlet with url, the servlet calls the webkit application with the url.
          In webkit application, the Qapplication initalize, exec and quit are called once only and it opens the url.
          When the request comes first time, everything goes well. But when the request comes second time, it doesn't come up. Thats why i have made simple to ask... But basically initialze, exec and quit is called by one request after another request
          Please suggest something?

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved