Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to create multiple windows in separated threads using Qt?

How to create multiple windows in separated threads using Qt?

Scheduled Pinned Locked Moved General and Desktop
10 Posts 2 Posters 7.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.
  • Z Offline
    Z Offline
    Zain
    wrote on last edited by
    #1

    Hello

    I want to open multiple windows using multithread with one window one thread on single click.

    Please solve this.

    Thanks
    Zain

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      You cannot. All Qt GUI objects must reside in the main program thread.

      Multiple non-GUI worker threads can communicate with GUI objects in the main thread using the signals/slots mechanism.

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        Zain
        wrote on last edited by
        #3

        Hello ChrisW67

        If it is not possible then please tell me another solution to create multiple webView on single click.

        1 Reply Last reply
        0
        • C Offline
          C Offline
          ChrisW67
          wrote on last edited by
          #4

          Threads are not required to have multiple windows. Something like:

          @
          void on_button_clicked() {
          QWebview *webView1 = new QWebView;
          webView1->setAttribute(Qt::WA_DeleteOnClose);
          webView1->load(QUrl("http://qt-project.org"));
          webView1->show();

          QWebview *webView2 = new QWebView;
          webView2->setAttribute(Qt::WA_DeleteOnClose);
          webView2->load(QUrl("http://google.com"));
          webView2->show();
          }
          @

          1 Reply Last reply
          0
          • Z Offline
            Z Offline
            Zain
            wrote on last edited by
            #5

            Thanks ChrisW67

            Also I want to set time for each webView. After particular time webView should be closed.

            So will it be feasible to use the code you have provided?

            1 Reply Last reply
            0
            • C Offline
              C Offline
              ChrisW67
              wrote on last edited by
              #6

              Yes, using QTimer (in combination with QTime if necessary) in any number of ways.

              1 Reply Last reply
              0
              • Z Offline
                Z Offline
                Zain
                wrote on last edited by
                #7

                Thanks ChristW67

                1 Reply Last reply
                0
                • Z Offline
                  Z Offline
                  Zain
                  wrote on last edited by
                  #8

                  Hello

                  There is issue in when i am setting timer.

                  I have used code as:

                  timer->stop

                  this give exception: "Exception at 0x61a3a53f, code: 0xc0000005: read access violation at: 0x0, flags=0x0"

                  1 Reply Last reply
                  0
                  • C Offline
                    C Offline
                    ChrisW67
                    wrote on last edited by
                    #9

                    The value of timer is null (0) or otherwise invalid, dereferencing a null pointer is bad.

                    1 Reply Last reply
                    0
                    • Z Offline
                      Z Offline
                      Zain
                      wrote on last edited by
                      #10

                      I am unable to solve multhreading functionality to load video on multiple webview & set proxy for it for particular time.

                      Please tell better solution for this.

                      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