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. Qt6.2.2 MessageDialog and FileDialog QML Type issue
Forum Updated to NodeBB v4.3 + New Features

Qt6.2.2 MessageDialog and FileDialog QML Type issue

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 1 Posters 925 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.
  • F Offline
    F Offline
    fromis_9
    wrote on last edited by fromis_9
    #1

    Hi. I'm using Qt 6.2 and I want to use FileDialog and MessageDialog from QtQuick.Dialogs.
    But this docs says the MessageDialog is not included in QtQuick.Dialogs of Qt 6.2.
    Although I tried to use the MessageDialog in QML, the compiler said that I needed to include Qt Widgets module to my project. So I did it, and it worked. So now I can use 'FileDialog' and 'MessageDialog' both in my project using Qt 6.2.
    However, after I included the 'Qt Widgets' module in my project, I couldn't use the FileDialog's currentFile property, with following error: "ReferenceError: selectedFile is not defined" I had used it before including Qt Widgets. Anyone know why?

    Target platform: Windows 10
    Using IDE: Visual Studio 2019 with Qt extension
    Using Qt versions: 6.2.2_msvc2019_62
    Using Modules: core, gui, widgets, qml, quickwidgets, quick, quickcontrols2

    code

    /// main.cpp
    
    #include <QApplication>
    // ...
    int main(int argc, char** argv)
    {
      QApplication app(argc, argv); 
      // .. some codes..
      return app.exec();
    }
    
    /// qml
    import QtQuick 2.9
    import QtQuick.Controls 2.12
    import QtQuick.Window 2.15
    import QtQuick.Dialogs
    import Qt.labs.platform
    
    Window {
      // some codes
      MessageDialog {
        // some codes
      }
      FileDialog {
        fileMode: FileDialog.SaveFile // works
        defaultSuffix: "avi" // works
        nameFilters: [ "avi (*.avi)" ] // works
        function saveopen() {
          currentFIle = new Date().toLocaleString(Qt.locale(), "yyMMddHHmmss")
          open() // works
        }
        onAccepted: {
          let fullLen = selectedFile.length // not defined 'selectedFile'
          var name = selectedFile.toString().substring(8, fullLen - 4)
          mycppbackend.method(name)
        }
      }
    }
    
    1 Reply Last reply
    0
    • F Offline
      F Offline
      fromis_9
      wrote on last edited by fromis_9
      #2

      I need to use Qt.labs.platform, rather QtQuick.Dialogs module because former contains MessageDialog and FileDialog both but latter is not. So I removeed "import QtQuick.Dialogs" above code. However, FileDialog from Qt.labs.platform does not contain "selectedFile" property, so I switch it to "currentFile" and it works.

      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