QT出现Error: Function.prototype.connect: target is not a function

import QtQuick 2.12//Text等
import QtQuick.Window 2.12
import QtQuick.Controls 1.3//button等组件

//信号槽
Window {
    id: win;
    visible: true//必须要写才能显示
     640;
    height: 480;
    color: "black";
    title: qsTr("Hello World");
    Text {
        id: txt;
        anchors.centerIn: parent;
        text: qsTr("Hello World");
        color: "blue";
        font.pointSize: 18;//适应缩放,使显示效果一样
        font.pixelSize: 24;//指定像素大小
    }
    //信号处理器的两种方式
    //窗口长宽改变时
    onWidthChanged: {
        txt.x = (win.width - txt.width) / 2;
    }
    onHeightChanged: heightChanged();
    function heightChanged(){
        txt.y = (win.height - txt.height) / 2;
    }

    Button {
        id: btn;
        x: 0;
        y: 0;
        text: "Quit";
    }
    //信号槽第一种方式
    function funcQuit() {
        Qt.quit();//全局退出函数
    }

    //方式一:
    Component.onCompleted: {
        btn.clicked.connect(funcQuit());//<------------------报错语句
    }

}

很明显提示说target不是一个函数,把函数带的括号去掉btn.clicked.connect(funcQuit)

原文地址:https://www.cnblogs.com/BASE64/p/14467078.html