Page 1 of 2 12 LastLast
Results 1 to 20 of 27

Thread: qrc:/main.qml:48:35: Unable to assign QQuickRectangle to QQuickAnchorLine

  1. #1
    Join Date
    Nov 2016
    Posts
    48
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default 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

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: qrc:/main.qml:48:35: Unable to assign QQuickRectangle to QQuickAnchorLine

    Sounds like a problem in the code.

    Something like
    Qt Code:
    1. anchors.left: parent
    To copy to clipboard, switch view to plain text mode 
    instead of
    Qt Code:
    1. anchors.left: parent.left
    To copy to clipboard, switch view to plain text mode 
    i.e. passing a reference to an object to an anchor line instead of passing the anchor line of that object.

    Cheers,
    _

  3. #3
    Join Date
    Nov 2016
    Posts
    48
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default 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.
    Qt Code:
    1. //main.qml
    2. import QtQuick 2.3//2.3 sur livre
    3.  
    4. Rectangle {
    5. width: 360
    6. height: 200
    7. color: "grey"
    8.  
    9. TextInput {
    10. id: argument1
    11. anchors.left: parent.left
    12. width: 160
    13. anchors.top: parent.top
    14. anchors.topMargin: 10
    15. anchors.leftMargin: 10
    16. anchors.rightMargin: 10
    17. text: "2"
    18. font.pointSize: 18
    19. }
    20.  
    21. TextInput {
    22. id: argument2
    23. anchors.right: parent.right
    24. width: 160
    25. anchors.top: parent.top
    26. anchors.topMargin: 10
    27. anchors.leftMargin: 10
    28. anchors.rightMargin: 10
    29. text: "2"
    30. font.pointSize: 18
    31. }
    32.  
    33. Text {
    34. id: result
    35. anchors.left: parent.left
    36. anchors.right: parent.right
    37. anchors.top: argument2.bottom
    38. anchors.topMargin: 10
    39. anchors.leftMargin: 10
    40. anchors.rightMargin: 10
    41. text: "4"
    42. font.pointSize: 24
    43. }
    44.  
    45. Row {
    46. id: buttonRow
    47. width: 317
    48. anchors.bottom: parent.bottom
    49. anchors.horizontalCenter: parent.hotizontalCenter//I added ".horizontalCenter". Now "debugging is enabled"
    50. anchors.bottomMargin: 20
    51. spacing: 20
    52. Button {
    53. id: plusButton
    54. operation: "+"
    55. onClicked: result.text = parseFloat(argument1.text) + parseFloat(argument2.text)
    56. }
    57.  
    58. Button {
    59. id: minusButton
    60. operation: "-"
    61. onClicked: result.text = parseFloat(argument1.text) - parseFloat(argument2.text)
    62. }
    63.  
    64. Button {
    65. id: timesButton
    66. operation: "*"
    67. onClicked: result.text = parseFloat(argument1.text) * parseFloat(argument2.text)
    68. }
    69.  
    70. Button {
    71. id: divideButton
    72. operation: "/"
    73. onClicked: result.text = parseFloat(argument1.text) / parseFloat(argument2.text)
    74. }
    75. }
    76. }
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default 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,
    _

  5. #5
    Join Date
    Nov 2016
    Posts
    48
    Qt products
    Qt5
    Platforms
    Unix/X11

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

  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default 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,
    _

  7. #7
    Join Date
    Nov 2016
    Posts
    48
    Qt products
    Qt5
    Platforms
    Unix/X11

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

  8. #8
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: qrc:/main.qml:48:35: Unable to assign QQuickRectangle to QQuickAnchorLine

    So everthing is working now?

    Cheers,
    _

  9. #9
    Join Date
    Nov 2016
    Posts
    48
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default 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.
    Qt Code:
    1. //Butoon.qml
    2. import QtQuick 2.0
    3. Rectangle {
    4. id: button
    5. width: 64
    6. height: 64
    7. property alias operation: buttonText.text
    8. signal clicked
    9. color: "green"
    10. Rectangle {
    11. id: shade
    12. anchors.fill: button;
    13. color: "black"; opacity: 0
    14. }
    15. Text {
    16. id: buttonText
    17. anchors.centerIn: parent;
    18. color: "white"
    19. font.pointSize: 16
    20. }
    21. MouseArea {
    22. id: mouseArea
    23. anchors.fill: parent
    24. onClicked: {
    25. button.clicked();
    26. }
    27. }
    28. states: State {
    29. name: "pressed"; when: mouseArea.pressed == true
    30. PropertyChanges { target: shade; opacity: .4 }
    31. }
    32. }
    To copy to clipboard, switch view to plain text mode 

  10. #10
    Join Date
    Nov 2016
    Posts
    48
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default 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

  11. #11
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: qrc:/main.qml:48:35: Unable to assign QQuickRectangle to QQuickAnchorLine

    Quote Originally Posted by sylas View Post
    Unfortunately it does not work.
    You have given no indication what problem you are having.

    Quote Originally Posted by sylas View Post
    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 View Post
    Now nothing about my first problem of anchor.
    Great.

    Quote Originally Posted by sylas View Post
    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,
    _

  12. #12
    Join Date
    Nov 2016
    Posts
    48
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default 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:
    Qt Code:
    1. //main.cpp
    2. #include <QtGui/QGuiApplication>
    3. #include "qtquick2applicationviewer.h"
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QGuiApplication app(argc, argv);
    8.  
    9. QtQuick2ApplicationViewer viewer;
    10. viewer.setMainQmlFile(QStringLiteral("qml/QtQuickCalculator/main.qml"));
    11. viewer.showExpanded();//origin
    12. // viewer.show();
    13.  
    14.  
    15. }
    To copy to clipboard, switch view to plain text mode 

  13. #13
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: qrc:/main.qml:48:35: Unable to assign QQuickRectangle to QQuickAnchorLine

    Quote Originally Posted by sylas View Post
    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 View Post
    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,
    _

  14. #14
    Join Date
    Nov 2016
    Posts
    48
    Qt products
    Qt5
    Platforms
    Unix/X11

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

  15. #15
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: qrc:/main.qml:48:35: Unable to assign QQuickRectangle to QQuickAnchorLine

    Quote Originally Posted by sylas View Post
    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 View Post
    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 View Post
    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,
    _

  16. #16
    Join Date
    Nov 2016
    Posts
    48
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default 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

  17. #17
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default 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,
    _

  18. #18
    Join Date
    Nov 2016
    Posts
    48
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default 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

  19. #19
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: qrc:/main.qml:48:35: Unable to assign QQuickRectangle to QQuickAnchorLine

    Quote Originally Posted by sylas View Post
    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 View Post
    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,
    _

  20. #20
    Join Date
    Nov 2016
    Posts
    48
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: qrc:/main.qml:48:35: Unable to assign QQuickRectangle to QQuickAnchorLine

    Trial.jpg
    You can see better with the image
    Attached Images Attached Images

Similar Threads

  1. Replies: 2
    Last Post: 8th August 2014, 19:08
  2. Unable to load background image in Main Window
    By bedbuffer in forum Newbie
    Replies: 0
    Last Post: 16th December 2010, 08:40
  3. Replies: 11
    Last Post: 11th August 2008, 09:14
  4. Replies: 1
    Last Post: 23rd July 2008, 10:19
  5. Replies: 15
    Last Post: 23rd March 2007, 16:16

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.