Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to load two complex window?
Qt 6.11 is out! See what's new in the release blog

How to load two complex window?

Scheduled Pinned Locked Moved QML and Qt Quick
20 Posts 2 Posters 6.4k 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.
  • small_birdS Offline
    small_birdS Offline
    small_bird
    wrote on last edited by small_bird
    #1

    Hi! Now I'd like to load two window in one qml application using loader of qml: one to play video, another to render 3d scene. As far a I am concerned, the two windows are running in two different thread. However, when I actually ran the application, it crashed. The shotcut is as following:

    alt text0_1506269349948_captured.JPG

    The application can only run one window at a time.Why? Could anyone tell me the reason? Thanks in advance!

    1 Reply Last reply
    0
    • R Offline
      R Offline
      RaubTieR
      wrote on last edited by RaubTieR
      #2

      I think there might be a problem with what you have inside those windows. Because if you take the very basic QtQuick app, that you get after "New project" wizard, you can end up with this working example quite easily:

      two windows

      Try to comment-out all the content and see if your setup works, then add components back to see what causes an error.

      small_birdS 2 Replies Last reply
      1
      • R RaubTieR

        I think there might be a problem with what you have inside those windows. Because if you take the very basic QtQuick app, that you get after "New project" wizard, you can end up with this working example quite easily:

        two windows

        Try to comment-out all the content and see if your setup works, then add components back to see what causes an error.

        small_birdS Offline
        small_birdS Offline
        small_bird
        wrote on last edited by
        #3

        @RaubTieR OK, I know that. Then what is the difference between using Loader to load Window component and nesting two windows?

        1 Reply Last reply
        0
        • R RaubTieR

          I think there might be a problem with what you have inside those windows. Because if you take the very basic QtQuick app, that you get after "New project" wizard, you can end up with this working example quite easily:

          two windows

          Try to comment-out all the content and see if your setup works, then add components back to see what causes an error.

          small_birdS Offline
          small_birdS Offline
          small_bird
          wrote on last edited by
          #4

          @RaubTieR I have tried that. However, the content in your window is too simple. One of my window has video playing. Another has complex 3d scene.

          1 Reply Last reply
          0
          • R Offline
            R Offline
            RaubTieR
            wrote on last edited by
            #5

            @small_bird Do you imply that as soon as you comment out the video component your setup works? I agree my windows are much simpler, but I suppose you want to know what exactly causes the error, and not by the means of vague comparison. So reduce your setup until it works first, then see what is the cause.

            I checked Video together with Loader and 2 Window-s, still works...

            2cats1qml

            small_birdS 1 Reply Last reply
            1
            • R RaubTieR

              @small_bird Do you imply that as soon as you comment out the video component your setup works? I agree my windows are much simpler, but I suppose you want to know what exactly causes the error, and not by the means of vague comparison. So reduce your setup until it works first, then see what is the cause.

              I checked Video together with Loader and 2 Window-s, still works...

              2cats1qml

              small_birdS Offline
              small_birdS Offline
              small_bird
              wrote on last edited by
              #6

              @RaubTieR I have seen your picture. But my is as following:
              0_1506347224397_captured.JPG
              It can only play one video at a time. Could you help me? Thanks in advance!

              1 Reply Last reply
              0
              • R Offline
                R Offline
                RaubTieR
                wrote on last edited by
                #7

                @small_bird I just don't know how to reproduce your problem. This is why I think it is easier to debug from your side. Did you manage to find a specific part of your code that causes the error?

                Or may be you could compose a minimal sample that would reproduce the behavior and post it here for others to actually have something to touch. As you've seen it is quite ok to run QML as you've described, so it must be something special for your case.

                PS: there were errors in your console logs from the first post, are you sure those do not contribute here?

                small_birdS 1 Reply Last reply
                0
                • R RaubTieR

                  @small_bird I just don't know how to reproduce your problem. This is why I think it is easier to debug from your side. Did you manage to find a specific part of your code that causes the error?

                  Or may be you could compose a minimal sample that would reproduce the behavior and post it here for others to actually have something to touch. As you've seen it is quite ok to run QML as you've described, so it must be something special for your case.

                  PS: there were errors in your console logs from the first post, are you sure those do not contribute here?

                  small_birdS Offline
                  small_birdS Offline
                  small_bird
                  wrote on last edited by
                  #8

                  @RaubTieR My source code structure is as following:

                    Window{
                        Video{
                            source: "...";
                        }
                        Window{
                        Video{
                            source: "...";
                        }
                    }
                  }
                  
                  1 Reply Last reply
                  0
                  • R Offline
                    R Offline
                    RaubTieR
                    wrote on last edited by
                    #9

                    @small_bird This is what I'm trying to say: the problem is not in the structure.

                    Look:
                    0_1506492595898_12f08db3-2776-4d24-a168-e7b2a28dcce9-image.png

                    I can easily get even 3 videos running. May be I ask you too many questions, but I do it with a clear intent. For me it was obvious from the beginning that multiwindow setup is OK for QML. This is why I insist on you answering those:

                    • Do you imply that as soon as you comment out the video component your setup works?
                    • So reduce your setup until it works first, then see what is the cause.
                    • Did you manage to find a specific part of your code that causes the error?
                    • Or may be you could compose a minimal sample that would reproduce the behavior and post it here for others to actually have something to touch.
                    • PS: there were errors in your console logs from the first post, are you sure those do not contribute here?

                    Also I've posted my example with three WORKING windows on github, now you are welcome to fork and break it according to your situation, then post it back. If you dare ;-)

                    small_birdS 1 Reply Last reply
                    1
                    • R RaubTieR

                      @small_bird This is what I'm trying to say: the problem is not in the structure.

                      Look:
                      0_1506492595898_12f08db3-2776-4d24-a168-e7b2a28dcce9-image.png

                      I can easily get even 3 videos running. May be I ask you too many questions, but I do it with a clear intent. For me it was obvious from the beginning that multiwindow setup is OK for QML. This is why I insist on you answering those:

                      • Do you imply that as soon as you comment out the video component your setup works?
                      • So reduce your setup until it works first, then see what is the cause.
                      • Did you manage to find a specific part of your code that causes the error?
                      • Or may be you could compose a minimal sample that would reproduce the behavior and post it here for others to actually have something to touch.
                      • PS: there were errors in your console logs from the first post, are you sure those do not contribute here?

                      Also I've posted my example with three WORKING windows on github, now you are welcome to fork and break it according to your situation, then post it back. If you dare ;-)

                      small_birdS Offline
                      small_birdS Offline
                      small_bird
                      wrote on last edited by small_bird
                      #10

                      @RaubTieR I have tried your code, but it still blocks.Two windows are all right, but three windows are blocked. My system is windows 7.

                      1 Reply Last reply
                      0
                      • R Offline
                        R Offline
                        RaubTieR
                        wrote on last edited by
                        #11

                        @small_bird what do you mean by "blocked"?
                        You downloaded my project, openned it, pressed run, and... then what happenned? Did you get any error message? I actually run it under win10, but today I will try on win7 (unsure if it actually matters).

                        small_birdS 1 Reply Last reply
                        0
                        • R RaubTieR

                          @small_bird what do you mean by "blocked"?
                          You downloaded my project, openned it, pressed run, and... then what happenned? Did you get any error message? I actually run it under win10, but today I will try on win7 (unsure if it actually matters).

                          small_birdS Offline
                          small_birdS Offline
                          small_bird
                          wrote on last edited by
                          #12

                          @RaubTieR said in How to load two complex window?:
                          I mean that one window plays video fluently, another can not play video fluently.

                          1 Reply Last reply
                          0
                          • R Offline
                            R Offline
                            RaubTieR
                            wrote on last edited by
                            #13

                            Tested on win7, and it goes fluently on all 3 windows. So it is most probably a performance issue for your machine.

                            Returning to the initial problem, did you manage to make it better? And what does actually happen there: no picture at all, or it becomes slow as it was with a video? I wonder if you have fixed those console errors yet...

                            small_birdS 1 Reply Last reply
                            0
                            • R RaubTieR

                              Tested on win7, and it goes fluently on all 3 windows. So it is most probably a performance issue for your machine.

                              Returning to the initial problem, did you manage to make it better? And what does actually happen there: no picture at all, or it becomes slow as it was with a video? I wonder if you have fixed those console errors yet...

                              small_birdS Offline
                              small_birdS Offline
                              small_bird
                              wrote on last edited by
                              #14

                              @RaubTieR There are still pictures. The movies can not play fluently. The console errors have been fixed.

                              1 Reply Last reply
                              0
                              • R Offline
                                R Offline
                                RaubTieR
                                wrote on last edited by
                                #15

                                @small_bird Did you test it on any other machines? What are your computer specs?

                                Your CPU seems to struggle handling so much data. May be the video is to tough, or may be you didn't limit the fps of your 3D scene. Though it doesn't explain how you have freezes with my example above. Try running it on different computers.

                                small_birdS 3 Replies Last reply
                                0
                                • R RaubTieR

                                  @small_bird Did you test it on any other machines? What are your computer specs?

                                  Your CPU seems to struggle handling so much data. May be the video is to tough, or may be you didn't limit the fps of your 3D scene. Though it doesn't explain how you have freezes with my example above. Try running it on different computers.

                                  small_birdS Offline
                                  small_birdS Offline
                                  small_bird
                                  wrote on last edited by
                                  #16

                                  @RaubTieR OK, I will try that!

                                  1 Reply Last reply
                                  0
                                  • R RaubTieR

                                    @small_bird Did you test it on any other machines? What are your computer specs?

                                    Your CPU seems to struggle handling so much data. May be the video is to tough, or may be you didn't limit the fps of your 3D scene. Though it doesn't explain how you have freezes with my example above. Try running it on different computers.

                                    small_birdS Offline
                                    small_birdS Offline
                                    small_bird
                                    wrote on last edited by
                                    #17

                                    @RaubTieR It runs well on other machine. It seems like my machine is too old, thanks a lot. Your cats are pretty cute!!!

                                    1 Reply Last reply
                                    0
                                    • R RaubTieR

                                      @small_bird Did you test it on any other machines? What are your computer specs?

                                      Your CPU seems to struggle handling so much data. May be the video is to tough, or may be you didn't limit the fps of your 3D scene. Though it doesn't explain how you have freezes with my example above. Try running it on different computers.

                                      small_birdS Offline
                                      small_birdS Offline
                                      small_bird
                                      wrote on last edited by small_bird
                                      #18

                                      @RaubTieR Your example is all right, however, mine still freezes. My code structure is as following:

                                      Window{
                                        Video{
                                          ...
                                        }
                                        Window{
                                          Scene3D{
                                            ...
                                          }
                                        }
                                      }
                                      

                                      The error output is as following:

                                      Starting C:\Users\Small_Bird\Desktop\gunHouse\debug\gunHouse.exe...
                                      QML debugging is enabled. Only use this in a safe environment.
                                      QThread::start: Failed to create thread ()
                                      
                                      This application has requested the Runtime to terminate it in an unusual way.
                                      Please contact the application's support team for more information.
                                      QThread::start: Failed to create thread ()
                                      QThread::start: Failed to create thread ()
                                      QThread::start: Failed to create thread ()
                                      Qt Concurrent has caught an exception thrown from a worker thread.
                                      This is not supported, exceptions thrown in worker threads must be
                                      caught before control returns to Qt Concurrent.
                                      terminate called after throwing an instance of 'std::bad_alloc'
                                        what():  std::bad_alloc
                                      
                                      1 Reply Last reply
                                      0
                                      • R Offline
                                        R Offline
                                        RaubTieR
                                        wrote on last edited by
                                        #19

                                        @small_bird Did I correctly understand that as sooun as you comment the "Video" section all the rest is working and the error "std::bad_alloc" goes away? Also are you sure that your machine has enough memory for your process (look at the task manager)? May be it first eats up all of it and then bails.

                                        small_birdS 1 Reply Last reply
                                        0
                                        • R RaubTieR

                                          @small_bird Did I correctly understand that as sooun as you comment the "Video" section all the rest is working and the error "std::bad_alloc" goes away? Also are you sure that your machine has enough memory for your process (look at the task manager)? May be it first eats up all of it and then bails.

                                          small_birdS Offline
                                          small_birdS Offline
                                          small_bird
                                          wrote on last edited by
                                          #20

                                          @RaubTieR No, it seems that the thread of Scene3D and that of Video mixes up with each other!

                                          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