qrc:/main.qml:48:35: Unable to assign QQuickRectangle to QQuickAnchorLine
Hi all ! Last year I built with success a quickcalculator. I used then the Linux O.S. 14. Now with my O.S 16 build fails at the moment I make it "run". I have the message I give on my title: qrc:/main.qml:48:35: Unable to assign QQuickRectangle to QQuickAnchorLine. I suppose that my new Qt Creator has some install missing. Have you an idea of what plugin is missing ?? Many thanks
Re: qrc:/main.qml:48:35: Unable to assign QQuickRectangle to QQuickAnchorLine
Sounds like a problem in the code.
Something like
Code:
anchors.left: parent
instead of
Code:
anchors.left: parent.left
i.e. passing a reference to an object to an anchor line instead of passing the anchor line of that object.
Cheers,
_
Re: qrc:/main.qml:48:35: Unable to assign QQuickRectangle to QQuickAnchorLine
Here is the code. Look please at the commented line. Thanks for your help.
Code:
//main.qml
import QtQuick 2.3//2.3 sur livre
Rectangle {
width: 360
height: 200
color: "grey"
TextInput {
id: argument1
anchors.left: parent.left
width: 160
anchors.top: parent.top
anchors.topMargin: 10
anchors.leftMargin: 10
anchors.rightMargin: 10
text: "2"
font.pointSize: 18
}
TextInput {
id: argument2
anchors.right: parent.right
width: 160
anchors.top: parent.top
anchors.topMargin: 10
anchors.leftMargin: 10
anchors.rightMargin: 10
text: "2"
font.pointSize: 18
}
Text {
id: result
anchors.left: parent.left
anchors.right: parent.right
anchors.top: argument2.bottom
anchors.topMargin: 10
anchors.leftMargin: 10
anchors.rightMargin: 10
text: "4"
font.pointSize: 24
}
Row {
id: buttonRow
width: 317
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.hotizontalCenter//I added ".horizontalCenter". Now "debugging is enabled"
anchors.bottomMargin: 20
spacing: 20
Button {
id: plusButton
operation: "+"
onClicked: result.text = parseFloat(argument1.text) + parseFloat(argument2.text)
}
Button {
id: minusButton
operation: "-"
onClicked: result.text = parseFloat(argument1.text) - parseFloat(argument2.text)
}
Button {
id: timesButton
operation: "*"
onClicked: result.text = parseFloat(argument1.text) * parseFloat(argument2.text)
}
Button {
id: divideButton
operation: "/"
onClicked: result.text = parseFloat(argument1.text) / parseFloat(argument2.text)
}
}
}
Re: qrc:/main.qml:48:35: Unable to assign QQuickRectangle to QQuickAnchorLine
anchors.horizontalCenter defnitely needs one of the three vertical anchor lines as its value, i.e. "parent.left", "parent.right" or "parent.horizontalCenter"
Just parent, which you had previously if I understood you correctly, would not work.
Btw, your code snippet above has a typo in the second "horizontalCenter"
Cheers,
_
Re: qrc:/main.qml:48:35: Unable to assign QQuickRectangle to QQuickAnchorLine
I tried the 3 cases. Now a paste of what happens with parent.horizontalCenter: QML debugging is enabled. Only use this in a safe environment.---- The problem appears onlly when I "run". No problem when it is building. It is strange this project worked well last year with my O.S Linux 14.O4. Now with my O.S. 16.04 it doesn't work.
Re: qrc:/main.qml:48:35: Unable to assign QQuickRectangle to QQuickAnchorLine
If you had "parent" as the value for the horizontalCenter then it just didn't report a warning, it definitely did not work.
Not having that anchor set might be ok, but then you could just remove it.
Cheers,
_
Re: qrc:/main.qml:48:35: Unable to assign QQuickRectangle to QQuickAnchorLine
I removed all the line with // Now "application output" says:
Starting /home/sylvain/build-quickcalc-Qt_5_5_1_in_PATH_qt5_invalid-Debug/quickcalc...
QML debugging is enabled. Only use this in a safe environment.
Nothing wrong while building. The above message appears only when I "run". This project comes from "Application Development with Qt Creator- 2nd edition" of the book of Ray Rischpater.
Re: qrc:/main.qml:48:35: Unable to assign QQuickRectangle to QQuickAnchorLine
So everthing is working now?
Cheers,
_
Re: qrc:/main.qml:48:35: Unable to assign QQuickRectangle to QQuickAnchorLine
Unfortunately it does not work. In the book he speeks only of two files, Button.qml and main.qml. No trace of a main.cpp. I already gave to you " main.qml " . I give you now "Button.qml". Maybe you can advance with it.
Code:
//Butoon.qml
import QtQuick 2.0
Rectangle {
id: button
width: 64
height: 64
property alias operation: buttonText.text
signal clicked
color: "green"
Rectangle {
id: shade
anchors.fill: button;
color: "black"; opacity: 0
}
Text {
id: buttonText
anchors.centerIn: parent;
color: "white"
font.pointSize: 16
}
MouseArea {
id: mouseArea
anchors.fill: parent
onClicked: {
button.clicked();
}
}
states: State {
name: "pressed"; when: mouseArea.pressed == true
PropertyChanges { target: shade; opacity: .4 }
}
}
Re: qrc:/main.qml:48:35: Unable to assign QQuickRectangle to QQuickAnchorLine
In the bundle of codes of this project I found many files. I added one viewer.cpp and a viewer.h. In the designer mode I see the calculator very well. It seems ready for use. Now nothing about my first problem of anchor. The only problem I have now is (in Application Output): "make sure to deploy Qt with accessibility plugins". Very well but where I can find these plugins ?? Have you an idea ?? Cheers
Re: qrc:/main.qml:48:35: Unable to assign QQuickRectangle to QQuickAnchorLine
Quote:
Originally Posted by
sylas
Unfortunately it does not work.
You have given no indication what problem you are having.
Quote:
Originally Posted by
sylas
In the book he speeks only of two files, Button.qml and main.qml. No trace of a main.cpp.
You don't necessarily need any C++ files.
E.g. you could simply launch main.qml using "qmlscene" or as a "QtQuick UI" project in QtCreator.
Quote:
Originally Posted by
sylas
Now nothing about my first problem of anchor.
Great.
Quote:
Originally Posted by
sylas
The only problem I have now is (in Application Output): "make sure to deploy Qt with accessibility plugins".
That's not a problem unless you need accessibility support.
Do you?
Cheers,
_
Re: qrc:/main.qml:48:35: Unable to assign QQuickRectangle to QQuickAnchorLine
I looked everywhere for Qt plugins, even with my terminal. Now nothing about plugins in "Application Output". I can see very well the calculator in the "Design" mode. But "show" impossible. Maybe there is an error in the main.cpp. Here is its code:
Code:
//main.cpp
#include <QtGui/QGuiApplication>
#include "qtquick2applicationviewer.h"
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QtQuick2ApplicationViewer viewer;
viewer.setMainQmlFile(QStringLiteral("qml/QtQuickCalculator/main.qml"));
viewer.showExpanded();//origin
// viewer.show();
}
Re: qrc:/main.qml:48:35: Unable to assign QQuickRectangle to QQuickAnchorLine
Quote:
Originally Posted by
sylas
I looked everywhere for Qt plugins, even with my terminal.
As I said, if you don't need accessiblity, don't bother looking for plugins that you don't need.
Quote:
Originally Posted by
sylas
But "show" impossible.
Why didn't you say so before?
So when you run the program you don't see a window or does the window not have any content?
Have you tried running the main.qml with "qmlscene"?
Cheers,
_
Re: qrc:/main.qml:48:35: Unable to assign QQuickRectangle to QQuickAnchorLine
1. I don't understand "running the main.qml with "qmlscene"".
2. The last message of "Application Output" is:
file:///home/sylvain/build-quickcalc-Qt_5_5_1_in_PATH_qt5_invalid-Debug/qml/QtQuickCalculator/main.qml: File not found
/home/sylvain/build-quickcalc-Qt_5_5_1_in_PATH_qt5_invalid-Debug/quickcalc exited with code 0
3. I must say to you that the name I gave to the project is "quickcalc", because I noticed with other projects that the name of the project is not compulsory.
Many thanks for your help.
Re: qrc:/main.qml:48:35: Unable to assign QQuickRectangle to QQuickAnchorLine
Quote:
Originally Posted by
sylas
1. I don't understand "running the main.qml with "qmlscene"".
qmlscene mai.qml
in a shell that has qmlscene in $PATH
Quote:
Originally Posted by
sylas
2. The last message of "Application Output" is:
file:///home/sylvain/build-quickcalc-Qt_5_5_1_in_PATH_qt5_invalid-Debug/qml/QtQuickCalculator/main.qml: File not found
See, an actual error message is way more informative than posting random bits of information.
Looks like the file you are trying to load does not exist or you have specified a wrong path.
Quote:
Originally Posted by
sylas
3. I must say to you that the name I gave to the project is "quickcalc", because I noticed with other projects that the name of the project is not compulsory.
Yes, the name of the project doesn't really matter.
Cheers,
_
Re: qrc:/main.qml:48:35: Unable to assign QQuickRectangle to QQuickAnchorLine
qmlscene: marvellous ! Calculator works very well. But is it possible you try yourself this demoniac quick application ? Only Button.qml and main.qml are necessary, and you have them above.1. you create the project with Qt Creator: "Application" and "QtQuickApplication"
2. main.cpp already appears. I don't touch it. (it is not the main.cpp I sent to you above). Now you add the file "Button.qml". You can look already in the Design mode the button.
3. You add "main.qml". You can look already in the design mode the calculator.
4. You build the project. No error message..
5. you run it. Then you see the "Application Output" message I gave at the beginning of this thread.
I think that if you don't have the message and your project works well the error is in my Linux or in a pluggin missing. Thank you very much. Cheers
Re: qrc:/main.qml:48:35: Unable to assign QQuickRectangle to QQuickAnchorLine
This has nothing to do with plugins, the error clearly indicates that the file does not exist where the program looks for it.
Most likely cause: the two QML files are in your project directory and you have a shadow build (out of source build).
So the working directory of the application is not the source directory.
Several options:
1) Start the application with the source directory as the working directory
2) Copy or link the QML files into the build directory
3) Put the QML files into a Qt resource and load them from there
Cheers,
_
Re: qrc:/main.qml:48:35: Unable to assign QQuickRectangle to QQuickAnchorLine
I use another project more complete. First paste of the "Application Output":
Starting /home/sylvain/build-quickcalc-Qt_5_5_1_in_PATH_qt5_invalid-Debug/quickcalc...
QML debugging is enabled. Only use this in a safe environment.
file:///home/sylvain/build-quickcalc-Qt_5_5_1_in_PATH_qt5_invalid-Debug/qml/QtQuickCalculator/main.qml: File not found
/home/sylvain/build-quickcalc-Qt_5_5_1_in_PATH_qt5_invalid-Debug/quickcalc exited with code 0
The files; quickcalc.pro, deployment.pri, qtquick2applicationviwer.h, main.cpp, qtquick2applicationviewer.cpp Ressources: Button.qml, main.qml Others: qmldir
It is very hard for me. Have you an idea ? Thanks and cheers
Re: qrc:/main.qml:48:35: Unable to assign QQuickRectangle to QQuickAnchorLine
Quote:
Originally Posted by
sylas
file:///home/sylvain/build-quickcalc-Qt_5_5_1_in_PATH_qt5_invalid-Debug/qml/QtQuickCalculator/main.qml: File not found
Your program, the last one and this one, tells you that there is no
/home/sylvain/build-quickcalc-Qt_5_5_1_in_PATH_qt5_invalid-Debug/qml/QtQuickCalculator/main.qml
file.
Quote:
Originally Posted by
sylas
It is very hard for me. Have you an idea ? Thanks and cheers
Files in a file system are address with by name, which consists of the the actual file name and path.
A path can be absolute or relative.
Absolute means it has all information there is, a full sequence of directory names from the top level of the directory tree to the file itself.
A relative path is just a filename or the filename plus some directories. The runtime environment will then prepend the program's working directory to create a full/absolute path for the actual access operation.
See https://en.wikipedia.org/wiki/Path_(computing)
Cheers,
_
2 Attachment(s)
Re: qrc:/main.qml:48:35: Unable to assign QQuickRectangle to QQuickAnchorLine
Attachment 12252
You can see better with the image