Results 1 to 20 of 27

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

Hybrid View

Previous Post Previous Post   Next Post Next Post
  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
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    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
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    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
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    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
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    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
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

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

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.