Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ Qt 5.7扩展弹出窗口(在文件qml/qqmlobjectcreator.cpp的第945行断言:“u currentList.object”)_C++_Qt_Qml_Qtquick2_Qtquickcontrols2 - Fatal编程技术网

C++ Qt 5.7扩展弹出窗口(在文件qml/qqmlobjectcreator.cpp的第945行断言:“u currentList.object”)

C++ Qt 5.7扩展弹出窗口(在文件qml/qqmlobjectcreator.cpp的第945行断言:“u currentList.object”),c++,qt,qml,qtquick2,qtquickcontrols2,C++,Qt,Qml,Qtquick2,Qtquickcontrols2,在Qt 5.7中使用自定义弹出窗口实现时,我遇到以下运行时错误(Qt 5.7是必需的,因为引入了弹出窗口,需要使用 -developer build标记以便导出私有符号(QQuickPopup类) 您可以尝试在MyItem.qml中将“CPopup”替换为“Popup”,您将看到它是有效的,因此问题需要在myCustomPopup类中继承自QQuickPopup的某个地方 错误:在文件qml/qqmlobjectcreator.cpp的第945行断言:“\u currentList.object

在Qt 5.7中使用自定义弹出窗口实现时,我遇到以下运行时错误(Qt 5.7是必需的,因为引入了弹出窗口,需要使用
-developer build
标记以便导出私有符号(QQuickPopup类)

您可以尝试在MyItem.qml中将“
CPopup
”替换为“
Popup
”,您将看到它是有效的,因此问题需要在my
CustomPopup
类中继承自
QQuickPopup
的某个地方

错误:
在文件qml/qqmlobjectcreator.cpp的第945行断言:“\u currentList.object”

项目:弹出式测试

poputest.pro

TEMPLATE = app

QT += gui qml quick quickcontrols2
QT_PRIVATE += quick-private core-private gui-private qml-private quickcontrols2-private quicktemplates2-private

CONFIG += c++11

SOURCES += main.cpp \
    custompopup.cpp

RESOURCES += qml.qrc

# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =

# Default rules for deployment.
include(deployment.pri)

HEADERS += \
    custompopup.h
custompopup.h

#ifndef CUSTOMPOPUP_H
#define CUSTOMPOPUP_H

#include <private/qquickpopup_p.h>

class CustomPopup : public QQuickPopup
{

    Q_OBJECT
    //Q_PROPERTY(QQmlListProperty<QObject> contentData READ contentData FINAL)
    //Q_CLASSINFO("DefaultProperty", "contentData")
public:
    CustomPopup(QObject *parent = nullptr);

protected:
    bool overlayEvent(QQuickItem *item, QEvent *event) override;

private:
    /*Q_DISABLE_COPY(CustomPopup)
    Q_DECLARE_PRIVATE(QQuickPopup)*/
};


QML_DECLARE_TYPE(CustomPopup)

#endif // CUSTOMPOPUP_H
MyItem.qml

import QtQuick 2.7
import QtQuick.Controls 1.5

ApplicationWindow {
    visible: true
    width: 600
    height: 480

    MyItem {
        anchors.fill: parent
    }
}
import QtQuick 2.0
import QtQuick.Controls 2.0
import Custom 1.0

Item {

    MouseArea {
        anchors.fill: parent
        acceptedButtons: Qt.RightButton
        onClicked: {
            menu.x = mouse.x
            menu.y = mouse.y
            menu.open()
        }

    }

    CPopup {
        id: menu
        Rectangle {
            width: 100
            height: 100
            color: "red"
        }
    }
}

我看不出片段中有任何可疑之处,但我现在无法尝试。请在bugreports.qt.io报告错误。谢谢
import QtQuick 2.7
import QtQuick.Controls 1.5

ApplicationWindow {
    visible: true
    width: 600
    height: 480

    MyItem {
        anchors.fill: parent
    }
}
import QtQuick 2.0
import QtQuick.Controls 2.0
import Custom 1.0

Item {

    MouseArea {
        anchors.fill: parent
        acceptedButtons: Qt.RightButton
        onClicked: {
            menu.x = mouse.x
            menu.y = mouse.y
            menu.open()
        }

    }

    CPopup {
        id: menu
        Rectangle {
            width: 100
            height: 100
            color: "red"
        }
    }
}