How to load two complex window?



  • 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:

    0_1506269349948_captured.JPG

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



  • 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.



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



  • @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.



  • @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



  • @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!



  • @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?



  • @RaubTieR My source code structure is as following:

      Window{
          Video{
              source: "...";
          }
          Window{
          Video{
              source: "...";
          }
      }
    }
    


  • @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 ;-)



  • @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.



  • @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).



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



  • 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...



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



  • @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.



  • @RaubTieR OK, I will try that!



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



  • @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
    


  • @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.



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.