Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LabelWithCaption binding loop #127

Open
ukenjutsu opened this issue Aug 16, 2021 · 3 comments
Open

LabelWithCaption binding loop #127

ukenjutsu opened this issue Aug 16, 2021 · 3 comments

Comments

@ukenjutsu
Copy link

ukenjutsu commented Aug 16, 2021

Qaterial.LabelWithCaption {
    anchors.centerIn: parent
    horizontalAlignment: Qt.AlignHCenter

    spacing: 10 // Binding loop detected for property "y"

    text: "I'm a simple label"
    caption: "Here is my caption text"

    textFont: Qaterial.Style.textTheme.headline5
    captionFont: Qaterial.Style.textTheme.body1
}

LabelWithCaption.qml: 48:3: QML Label: Binding loop detected for property "y"

Same problems with CaptionWithLabel, OverlineWithLabel and "maybe" IconLabelWithCaption, but I haven't tested it because IconLabelWithCaption (sure IconLabel too) doesn't work for me. It says "Could not resolve the prototype for Qaterial.IconLabelImpl" :(

@ukenjutsu ukenjutsu changed the title LabelWithCaption / CaptionWithLabel binding loop LabelWithCaption binding loop Aug 16, 2021
@OlivierLDff
Copy link
Owner

Are you sure you added qrc:/ to your import path.

QQmlApplicationEngine engine;
engine.addImportPath("qrc:/");

And binding loop seems to be cause by

y:
{
if(root.verticalAlignment === Qt.AlignVCenter)
return Math.floor((root.height - root.implicitHeight) / 2)
if(root.verticalAlignment === Qt.AlignBottom)
return root.height - root.implicitHeight
return 0
}

I guess solution to avoid the binding loop is to either move implementation to cpp, or to change approach to use a column

@ukenjutsu
Copy link
Author

ukenjutsu commented Aug 17, 2021

I just removed the spacing property for temporary fix the binding loop

I tested IconLabel again. It works and displays an icon, but QtCreator highlights it as an unresolved component
Adding the engine.addImportPath("qrc:/"); does not solve this problem. On the contrary, it gives me even more problems.
I am using Qaterial installed via CMAKE_INSTALL, and i put .qml files to Qt source folder C:\Qt\5.15.2\msvc2019_64\qml\Qaterial and if there is a warning in some qml file, QtCreator cannot open this file, because the location of this file is somewhere in the resource which I don't have qrc:/Qaterial/LabelWithCaption.qml:48:3: QML Label: Binding loop detected for property "y".

I think I included the Qaterial library incorrectly

Here is my little CMakeLists.txt

(sorry for bad english)

@OlivierLDff
Copy link
Owner

Easiest way to add Qaterial is using something like that : https://github.com/OlivierLDff/QaterialHotReload/blob/master/cmake/FetchQaterial.cmake
I think find_package is fine, but I'm not using this technique myself.
I'm also not using QtCreator so I can't give you any help on that sorry.
I think to have correct completation within QtCreator, you need to generate a qmltype file : https://doc.qt.io/qtcreator/creator-qml-modules-with-plugins.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants