Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Qt 5.7 Extending Popup (ASSERT: "_currentList.object" in file qml/qqmlobjectcreator.cpp, line 945)

Qt 5.7 Extending Popup (ASSERT: "_currentList.object" in file qml/qqmlobjectcreator.cpp, line 945)

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 514 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.
  • K Offline
    K Offline
    KrabQT
    wrote on 25 Jun 2016, 14:39 last edited by KrabQT
    #1

    I got the runtime error below when using my custom popup implementation with Qt 5.7 (Qt 5.7 is necessary because there is introduced Popup and it needs to be compiled with
    -developer-build flag so private symbols (QQuickPopup class) are exported).

    You can try replace "CPopup" with "Popup" in MyItem.qml and you will see it works, so the problem needs to be somewhere with the inheritance from QQuickPopup in my CustomPopup class.

    ERROR: ASSERT: "_currentList.object" in file qml/qqmlobjectcreator.cpp, line 945

    https://github.com/qt/qtquickcontrols2/blob/5.7/src/quicktemplates2/qquickpopup_p.h
    https://github.com/qt/qtquickcontrols2/blob/5.7/src/quicktemplates2/qquickpopup.cpp
    https://github.com/qt/qtdeclarative/blob/dev/src/qml/qml/qqmlobjectcreator_p.h
    https://github.com/qt/qtdeclarative/blob/dev/src/qml/qml/qqmlobjectcreator.cpp

    PROJECT: popuptest

    popuptest.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
    

    custompopup.cpp

    #include "custompopup.h"
    
    CustomPopup::CustomPopup(QObject *parent) : QQuickPopup(parent)
    {
    
    }
    
    bool CustomPopup::overlayEvent(QQuickItem *item, QEvent *event)
    {
            /*QQuickPopup implementation
            Q_D(QQuickPopup);
            switch (event->type()) {
            case QEvent::KeyPress:
            case QEvent::KeyRelease:
            case QEvent::MouseMove:
            case QEvent::Wheel:
                if (d->modal)
                    event->accept();
                return d->modal;
    
            case QEvent::MouseButtonPress:
            case QEvent::MouseButtonRelease:
                if (d->modal)
                    event->accept();
                d->tryClose(item, static_cast<QMouseEvent *>(event));
                return d->modal;
    
            default:
                return false;
            }
            */
       // Q_D(QQuickPopup);
        return QQuickPopup::overlayEvent(item, event);
    }
    

    main.cpp

    #include <QGuiApplication>
    #include <QQmlApplicationEngine>
    #include "custompopup.h"
    
    int main(int argc, char *argv[])
    {
        QGuiApplication app(argc, argv);
    
        QQmlApplicationEngine engine;
    
        qmlRegisterType<CustomPopup>("Custom", 1, 0, "CPopup");
    
        engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
    
        return app.exec();
    }
    

    main.qml

    import QtQuick 2.7
    import QtQuick.Controls 1.5
    
    ApplicationWindow {
        visible: true
        width: 600
        height: 480
    
        MyItem {
            anchors.fill: parent
        }
    }
    

    MyItem.qml

    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"
            }
        }
    }
    
    1 Reply Last reply
    0

    1/1

    25 Jun 2016, 14:39

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved