qml pyqt5 信号槽连接问题

zzone 发布于 2015/05/31 09:49
阅读 550
收藏 0
import sys
from PyQt5.QtCore import QObject, QUrl, Qt
from PyQt5.QtWidgets import QApplication
from PyQt5.QtQml import QQmlApplicationEngine

def show(text):
   print(text)


if __name__ == "__main__":
  app = QApplication(sys.argv)
  engine = QQmlApplicationEngine()



  engine.load('main.qml')

  win = engine.rootObjects()[0]

  win.show()
  sys.exit(app.exec_())  



import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Layouts 1.1

ApplicationWindow{
   visible:true
   width:640
   height:480
   id:window
   title:asTr("editor")
      
   signal show(string text)



   TextArea{
      text:"hello"
      onTextChanged:show(text);
   }
   
}






请问各位大神,我想要把python 中的show方法和qml中的show信号连接起来,我该怎么做呢?
加载中
返回顶部
顶部