Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Cusom widget crash every time on setGeometry() #29

Open
akontsevich opened this issue Nov 5, 2020 · 0 comments
Open

Cusom widget crash every time on setGeometry() #29

akontsevich opened this issue Nov 5, 2020 · 0 comments

Comments

@akontsevich
Copy link

akontsevich commented Nov 5, 2020

Created custom widget like this:

class DeclarativeMyWidgetExtension : public DeclarativeWidgetExtension
{
    Q_OBJECT

public:
    // Repeat property declarations, qmlRegisterExtendedType doesn't see the ones from
    // base class
    Q_PROPERTY(QQmlListProperty<QObject> data READ data DESIGNABLE false CONSTANT)
    Q_PROPERTY(int x READ x WRITE setX NOTIFY posChanged)
    Q_PROPERTY(int y READ y WRITE setY NOTIFY posChanged)
    Q_PROPERTY(int width READ width WRITE setWidth NOTIFY sizeChanged)
    Q_PROPERTY(int height READ height WRITE setHeight NOTIFY sizeChanged)
    Q_PROPERTY(QRect geometry READ geometry WRITE setGeometry NOTIFY geometryChanged)
    Q_PROPERTY(DeclarativeSizePolicy *sizePolicy READ sizePolicy CONSTANT)

}

In QML:

        MyWidget {
            x: 0
            y: 0
            width: parentItem.width
            height: parentItem.height
        }

However it crashes on this line: https://github.com/KDAB/DeclarativeWidgets/blob/master/src/declarativewidgetextension.cpp#L160 or this: https://github.com/KDAB/DeclarativeWidgets/blob/master/src/declarativewidgetextension.cpp#L177

If width or height are fixed - no crash.

Also can't add

  Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)

property, getting build error:

moc_DeclarativeMyWidgetExtension.cpp: In function ‘void checkNotifySignalValidity_DeclarativeMyWidgetExtension(DeclarativeMyWidgetExtension*)’:
moc_DeclarativeMyWidgetExtension.cpp:232:23: error: no matching function for call to ‘DeclarativeMyWidgetExtension::visibleChanged()’
  232 |     t->visibleChanged();
      |                       ^
In file included from ../DeclarativeMyWidgetExtension.h:4,
                 from moc_DeclarativeMyWidgetExtension.cpp:9:
/src/declarativewidgetextension.h:96:10: note: candidate: ‘void DeclarativeWidgetExtension::visibleChanged(bool)’
   96 |     void visibleChanged(bool visible);
      |          ^~~~~~~~~~~~~~
/src/declarativewidgetextension.h:96:10: note:   candidate expects 1 argument, 0 provided
make: *** [Makefile:378283: moc_DeclarativeMyWidgetExtension.o] Error 1
@akontsevich akontsevich changed the title Cusom widget crash everyt time on setGeometry Cusom widget crash every time on setGeometry() Nov 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant