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. Error/warning at exit with qml/filedialog
Forum Updated to NodeBB v4.3 + New Features

Error/warning at exit with qml/filedialog

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 2 Posters 552 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.
  • SietseAchteropS Offline
    SietseAchteropS Offline
    SietseAchterop
    wrote on last edited by SietseAchterop
    #1

    Hello list,

    When the following simple app is ended using the closing button, I get:

     QObject::startTimer: Timers can only be used with threads started with QThread
    

    This has to do with the FileDialog. For each FileDialog in the qml-file I get an extra error.
    Here the main.py and main.qml

    import sys
    from PyQt5.QtGui import QGuiApplication
    from PyQt5.QtQml import QQmlApplicationEngine
    
    def main():
    
        app = QGuiApplication(sys.argv)
    
        app.setOrganizationName("RTC noord")
        app.setOrganizationDomain("RTC")
        app.setApplicationName("RtcNoordApp")
    
        engine = QQmlApplicationEngine(parent=app)
    
        engine.load("qml/test-main.qml")
    
        engine.quit.connect(app.quit)
        sys.exit(app.exec_())
    
    if __name__ == "__main__":
        main()
    
    
    import QtQuick 2.13
    import QtQuick.Controls 2.13
    import QtQuick.Layouts 1.12
    import QtQuick.Dialogs 1.3
    
    ApplicationWindow {
        id: applicationWindow
        visible: true
        width: 900
        height: 600
        title: qsTr("RTCNoord")
    
        FileDialog {
            id: filedialog
            nameFilters: ["CSV files (*.csv)", "All Files (*.*)"]
    	folder: '/tmp'
            onAccepted: {
                draw_mpl.createSessionCsv(fileUrl);
    	    
            }
        } 
    
        Text {
    	text: "some text"
        }
    
    }
    
    

    It has something to do with threads, in the FileDialog presumably, but what am I doing wrong here?
    Thanks in advance,
    Sietse

    PS. This is on debian buster with current software

    rrlopezR 1 Reply Last reply
    0
    • SietseAchteropS SietseAchterop

      Hello list,

      When the following simple app is ended using the closing button, I get:

       QObject::startTimer: Timers can only be used with threads started with QThread
      

      This has to do with the FileDialog. For each FileDialog in the qml-file I get an extra error.
      Here the main.py and main.qml

      import sys
      from PyQt5.QtGui import QGuiApplication
      from PyQt5.QtQml import QQmlApplicationEngine
      
      def main():
      
          app = QGuiApplication(sys.argv)
      
          app.setOrganizationName("RTC noord")
          app.setOrganizationDomain("RTC")
          app.setApplicationName("RtcNoordApp")
      
          engine = QQmlApplicationEngine(parent=app)
      
          engine.load("qml/test-main.qml")
      
          engine.quit.connect(app.quit)
          sys.exit(app.exec_())
      
      if __name__ == "__main__":
          main()
      
      
      import QtQuick 2.13
      import QtQuick.Controls 2.13
      import QtQuick.Layouts 1.12
      import QtQuick.Dialogs 1.3
      
      ApplicationWindow {
          id: applicationWindow
          visible: true
          width: 900
          height: 600
          title: qsTr("RTCNoord")
      
          FileDialog {
              id: filedialog
              nameFilters: ["CSV files (*.csv)", "All Files (*.*)"]
      	folder: '/tmp'
              onAccepted: {
                  draw_mpl.createSessionCsv(fileUrl);
      	    
              }
          } 
      
          Text {
      	text: "some text"
          }
      
      }
      
      

      It has something to do with threads, in the FileDialog presumably, but what am I doing wrong here?
      Thanks in advance,
      Sietse

      PS. This is on debian buster with current software

      rrlopezR Offline
      rrlopezR Offline
      rrlopez
      wrote on last edited by
      #2

      @SietseAchterop Hello, does createSessionCsv trigger a startTimer? I assume that you start a timer from somewhere in your code and then on program exit we try to interact with this timer and since it is not on the same context where the timer was created then we get the warning. If you start the app and close it right away does the warning shows?

      Lic-Ing. Rodrigo Lopez Gonzalez
      Embedded Software Engineer
      RidgeRun Engineering Ltd.
      www.ridgerun.com
      Email: rodrigo.lopez@ridgerun.com

      1 Reply Last reply
      0
      • SietseAchteropS Offline
        SietseAchteropS Offline
        SietseAchterop
        wrote on last edited by
        #3

        Thank for the reply.
        I do not use timers at all in my app.
        The problem shows up the moment I have a FileDialog in the qml file.
        I assume that in FileDialog a timer is used somehow.
        But I have no control over that.

        The onAccepted was a bit confusing. Same problem if there is no onAccepted at all. I can then open and close the app directly.
        The problem stays the same. The above code is all there is.

        Regards, Sietse
        
        rrlopezR 1 Reply Last reply
        0
        • SietseAchteropS SietseAchterop

          Thank for the reply.
          I do not use timers at all in my app.
          The problem shows up the moment I have a FileDialog in the qml file.
          I assume that in FileDialog a timer is used somehow.
          But I have no control over that.

          The onAccepted was a bit confusing. Same problem if there is no onAccepted at all. I can then open and close the app directly.
          The problem stays the same. The above code is all there is.

          Regards, Sietse
          
          rrlopezR Offline
          rrlopezR Offline
          rrlopez
          wrote on last edited by
          #4

          @SietseAchterop I don't see any timer usage on the FileDialog documentation. I think you need to call Qt.quit() on the onAccepted of your dialog to close the window when you choose an option.
          https://doc.qt.io/qt-5/qml-qtquick-dialogs-filedialog.html

          Lic-Ing. Rodrigo Lopez Gonzalez
          Embedded Software Engineer
          RidgeRun Engineering Ltd.
          www.ridgerun.com
          Email: rodrigo.lopez@ridgerun.com

          1 Reply Last reply
          0
          • SietseAchteropS Offline
            SietseAchteropS Offline
            SietseAchterop
            wrote on last edited by SietseAchterop
            #5

            No, neither do I, but calling Qt.quit() is not correct.
            I don't want the application to quit when I select a file.
            Anyway it is not relevant, because you can see in the example that I cannot use the FileDialog in this simplified example, there is no menu e.g.
            And onAccepted is not used by immediately closing the app anyhow.

            But only the FileDialog in the qml-file already triggers the behaviour.
            Weird.

            Sietse

            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