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. PyQt, after app quit, my command line is unresponsive
QtWS25 Last Chance

PyQt, after app quit, my command line is unresponsive

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 2.2k 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.
  • J Offline
    J Offline
    Jinxvar
    wrote on last edited by
    #1

    Hi, I have some weird behaviour that I can not understand.
    I run this code "python3 ToonPi.py" from my Raspberry Pi command line.
    This generates a screen with picture and button using PyQt5 and Qt5.5. When I click the button the app quits, so far so good.
    However, from that point on my command line no longer works and I can not see the blinking line which I
    normally see when I want to type something in. I have to reboot my RPi to try again.
    Anyone have any idea on this?

    Below are both the py file and the QML file.
    QML File

    import QtQuick 2.3
    import QtQuick.Controls 1.4
    
    ApplicationWindow {
        id: window
        visible: true
    	width: 800; height: 480
    
    	Rectangle {
    		id: screen
    		width: 800; height: 480
    
    		SystemPalette { id: activePalette }
    
    		Item {
    			width: parent.width
    			anchors { top: parent.top; bottom: toolBar.top }
    
    			Image {
    				id: background
    				anchors.fill: parent
    				source: "./pics/toonback.png"
    				fillMode: Image.PreserveAspectCrop
    			}
    		}
    
    		Button{
    			x: 100
    			y: 100
    			text : "Quit"
    			onClicked: {
    				Qt.quit()
    			}
    		}
    		
    		Rectangle {
    			id: toolBar
    			width: parent.width; height: 30
    			color: activePalette.window
    			anchors.bottom: screen.bottom
    
    
    			Text {
    				id: score
    				anchors { right: parent.right; verticalCenter: parent.verticalCenter }
    				text: "Score: Who knows?"
    			}
    		}
    		
    	}
    }
    

    And the Python file

    import sys
    from PyQt5.QtWidgets import QApplication
    from PyQt5.QtQml import QQmlApplicationEngine
    
    
    def main():
    
        engine = QQmlApplicationEngine("basic.qml")
        engine.quit.connect(myApp.quit)
    
        # Execute the Application and Exit
        myApp.exec_()
    
    # Main Function
    if __name__ == '__main__':
        # Create main app
        myApp = QApplication(sys.argv)
        sys.exit(main())
    
    1 Reply Last reply
    1
    • M Offline
      M Offline
      Metavoid
      wrote on last edited by
      #2

      hello,
      So reset or clear wont make it "blink" again?

      1 Reply Last reply
      0
      • J Offline
        J Offline
        Jinxvar
        wrote on last edited by
        #3

        You mean reboot? After reboot its fine.
        What do you mean by reset or clear?

        1 Reply Last reply
        0
        • David.GD Offline
          David.GD Offline
          David.G
          wrote on last edited by
          #4

          Perhaps because you are not returning the value. There's no return.

          Did you try adding

          return myApp.exec_()
          

          exec_() will return an integer. (usually 0)

          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