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. [SOLVED] - qml sandboxing of components
QtWS25 Last Chance

[SOLVED] - qml sandboxing of components

Scheduled Pinned Locked Moved QML and Qt Quick
10 Posts 3 Posters 3.7k Views
  • 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.
  • H Offline
    H Offline
    harchu
    wrote on 28 Aug 2014, 23:38 last edited by
    #1

    Hi, I am new to Qt/QML. I was wondering if there is a way to sandbox qml components that are loaded from external qml files (either using Loader or javascript - createComponent/createObject) in the application. Also, which is the preferred method to load these external files?
    Thank you,
    Rohit

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dheerendra
      Qt Champions 2022
      wrote on 29 Aug 2014, 02:25 last edited by
      #2

      welcome to the forum. You can you put all the QML components in specific directory. You can add the path using QmlEngine::addImportPath.. or QML_IMPORT_PATH environment variable or

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      0
      • H Offline
        H Offline
        harchu
        wrote on 29 Aug 2014, 17:38 last edited by
        #3

        Thanks.
        Actually what i meant to ask was - is there a way to prevent the loaded component/object from accessing the parent object or its siblings?

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dheerendra
          Qt Champions 2022
          wrote on 4 Sept 2014, 03:57 last edited by
          #4

          There is no way to do this. What are you trying to prevent ? You can dis-associate parent and child relation ship by changing the parent.

          Dheerendra
          @Community Service
          Certified Qt Specialist
          http://www.pthinks.com

          1 Reply Last reply
          0
          • H Offline
            H Offline
            harchu
            wrote on 4 Sept 2014, 15:33 last edited by
            #5

            I am trying to load a qml created by some 3rd party, but do not want it to change/add/delete widgets/properties on my application. I think its mandatory to have this feature for security purposes.

            How do I change the parent? I still want to display the widgets specified in the qml in my application.

            1 Reply Last reply
            0
            • D Offline
              D Offline
              dheerendra
              Qt Champions 2022
              wrote on 5 Sept 2014, 04:15 last edited by
              #6

              ok. I got it. Conceptually how will the third app know about your code/app/object name etc in your code ? You will be using the third party component. Whatever it does it will be within it's own code. So your code is controlling the third party component. So I feel this issue may not arise. Hope I'm not missing something in your explanation or thought process.

              Dheerendra
              @Community Service
              Certified Qt Specialist
              http://www.pthinks.com

              1 Reply Last reply
              0
              • J Offline
                J Offline
                jeremy_k
                wrote on 5 Sept 2014, 09:05 last edited by
                #7

                An instance of a QML component can always walk its way up the parent chain until it reaches the ultimate parent in the context, and then inspect the children.

                One option is to place the 3rd party code in a separate QML context, making access to other objects harder.

                Asking a question about code? http://eel.is/iso-c++/testcase/

                1 Reply Last reply
                0
                • H Offline
                  H Offline
                  harchu
                  wrote on 5 Sept 2014, 23:58 last edited by
                  #8

                  @dheerendra: the third party qml component can walk up the parent chain and then look at other children of the parents...which is something i want to prevent

                  @jeremy_k: how do i create a separate QML context when i am dynamically loading these QML components? can you point me to some documentation or some examples. Thanks.

                  1 Reply Last reply
                  0
                  • J Offline
                    J Offline
                    jeremy_k
                    wrote on 6 Sept 2014, 00:12 last edited by
                    #9

                    The only way I know of creating a separate context is to use a new QQmlEngine, QQuickWindow, or derived class.

                    Depending on what the third party code is expected to do, maybe it should go in its own window, or even in a new process.

                    Asking a question about code? http://eel.is/iso-c++/testcase/

                    1 Reply Last reply
                    0
                    • H Offline
                      H Offline
                      harchu
                      wrote on 29 Oct 2014, 22:50 last edited by
                      #10

                      I was able to achieve this by creating a new QML component which basically creates a new Engine and loads the source in there. Also any access to the parent property from this sandboxed component returns a null.

                      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