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. What to import for Qml File Dialog
Qt 6.11 is out! See what's new in the release blog

What to import for Qml File Dialog

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 1.2k 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.
  • I Offline
    I Offline
    IanHowell
    wrote on last edited by
    #1

    I'm currently trying to access a QML File Dialog object from a C++ QQuickItem, but I can't figure out what to cast it to or where to import from. The doc page at http://doc.qt.io/qt-5/qml-qtquick-dialogs-filedialog.html doesn't give a C++ integration import, just the import for QML files. Does anyone know what the import is, or where I can find it in the future?

    raven-worxR 1 Reply Last reply
    0
    • I IanHowell

      I'm currently trying to access a QML File Dialog object from a C++ QQuickItem, but I can't figure out what to cast it to or where to import from. The doc page at http://doc.qt.io/qt-5/qml-qtquick-dialogs-filedialog.html doesn't give a C++ integration import, just the import for QML files. Does anyone know what the import is, or where I can find it in the future?

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @IanHowell
      not all QML components (actually very little do) also export the C++ API.
      Components implemented outside QtQuick (the ones implemented with plugins) actually never do IIRC

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      1
      • I Offline
        I Offline
        IanHowell
        wrote on last edited by
        #3

        Alright, so should I create 'controller components' to make use of them? Like:

        FileDialogController {
            FileDialog {
                visible: fileDialogController.visible
            }
        }
        

        Where the FileDialogController has a boolean Q_PROPERTY visible? Would this be good practice (not this example in specific but as a general trend)?

        raven-worxR 1 Reply Last reply
        0
        • I IanHowell

          Alright, so should I create 'controller components' to make use of them? Like:

          FileDialogController {
              FileDialog {
                  visible: fileDialogController.visible
              }
          }
          

          Where the FileDialogController has a boolean Q_PROPERTY visible? Would this be good practice (not this example in specific but as a general trend)?

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          @IanHowell
          i actually don't even know what you want to achieve exactly

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • I Offline
            I Offline
            IanHowell
            wrote on last edited by
            #5

            I basically want to be able to open the file dialog from a C++ qquickitem subclass.

            raven-worxR 1 Reply Last reply
            0
            • I IanHowell

              I basically want to be able to open the file dialog from a C++ qquickitem subclass.

              raven-worxR Offline
              raven-worxR Offline
              raven-worx
              Moderators
              wrote on last edited by
              #6

              @IanHowell
              so yes if you like your approach go with it.
              Alternatively you can also get a QQuickItem* (by defining a Q_PROPERTY or via a Q_INVOKABLE method) to your "controller" class.

              In there you should be able to call methods on the item and access it's properties even without knowing it's exact type:

              QQuickItem* item = ...
              // call method
              QMetaObject::invokeMethod(item, "methodName", Qt::AutoConnection);
              
              // read property
              QVariant v = QQmlProperty::read(item, "propertyName");
              

              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
              If you have a question please use the forum so others can benefit from the solution in the future

              1 Reply Last reply
              1

              • Login

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