gpt4 book ai didi

c++ - 无法连接 qml 信号和 c++ 插槽

转载 作者:太空宇宙 更新时间:2023-11-04 13:01:23 25 4
gpt4 key购买 nike

<分区>

我正在尝试将 QML 信号连接到 C++ 插槽。但是当我继续使用 Qt guide 时,会出现两个错误:

file:///home/muhammad/Documents/qt_projects/build-Plaq-Desktop_Qt_5_8_0_GCC_64bit-Debug/qrc:/main.qml: No such file or directory

QObject::connect: Cannot connect (null)::qmlSignal(QString) to PlaqueFinder::cppSlot(QString)

这是我在 main.cpp 中的代码:

#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <plaquefinder.h>
#include <QQuickView>
#include <QString>
#include <QObject>
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);

QQmlApplicationEngine engine;
engine.load(QUrl(QLatin1String("qrc:/main.qml")));
QQuickView view(QUrl::fromLocalFile("qrc:/main.qml"));
QObject* item = (QObject*)view.rootObject();
PlaqueFinder plaq;
QObject::connect(item, SIGNAL(qmlSignal(QString)),
&plaq, SLOT(cppSlot(QString)));

return app.exec();
}

我该如何解决?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com