Results 1 to 19 of 19

Thread: View possible in the design mode and qmlscene but not at the end or"run"

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

    Default View possible in the design mode and qmlscene but not at the end or"run"

    Hi all ! No problem during the building. At the end of "run" the message of Application Output is: Button is not a type (in main.qml).. This looks like a nonsense. I give you below the two codes of "Button.qml" and "main.qml". The main.cpp is constructed by QtCreator. This project comes from a book.There are many days I try to finish this project, without success.I hope somebody will help me.
    Qt Code:
    1. //button.qml
    2. import QtQuick 2.0
    3.  
    4. Rectangle {
    5. id: button
    6.  
    7. width: 64
    8. height: 64
    9.  
    10. property alias operation: buttonText.text
    11. signal clicked
    12.  
    13. color: "green"
    14.  
    15. Rectangle {
    16. id: shade
    17. anchors.fill: button;
    18. color: "black"; opacity: 0
    19. }
    20.  
    21. Text {
    22. id: buttonText
    23. anchors.centerIn: parent;
    24. color: "white"
    25. font.pointSize: 16
    26. }
    27.  
    28. MouseArea {
    29. id: mouseArea
    30. anchors.fill: parent
    31. onClicked: {
    32. button.clicked();
    33. }
    34. }
    35.  
    36. states: State {
    37. name: "pressed"; when: mouseArea.pressed == true
    38. PropertyChanges { target: shade; opacity: .4 }
    39. }
    40. }
    To copy to clipboard, switch view to plain text mode 
    Next
    Qt Code:
    1. //main.qml
    2. import QtQuick 2.3
    3. import QtQuick.Window 2.2
    4.  
    5. Rectangle {
    6. width: 360
    7. height: 200
    8. color: "grey"
    9.  
    10. TextInput {
    11. id: argument1
    12. anchors.left: parent.left
    13. width: 160
    14. anchors.top: parent.top
    15. anchors.topMargin: 10
    16. anchors.leftMargin: 10
    17. anchors.rightMargin: 10
    18. text: "2"
    19. font.pointSize: 18
    20. }
    21.  
    22. TextInput {
    23. id: argument2
    24. anchors.right: parent.right
    25. width: 160
    26. anchors.top: parent.top
    27. anchors.topMargin: 10
    28. anchors.leftMargin: 10
    29. anchors.rightMargin: 10
    30. text: "2"
    31. font.pointSize: 18
    32. }
    33.  
    34. Text {
    35. id: result
    36. anchors.left: parent.left
    37. anchors.right: parent.right
    38. anchors.top: argument2.bottom
    39. anchors.topMargin: 10
    40. anchors.leftMargin: 10
    41. anchors.rightMargin: 10
    42. text: "4"
    43. font.pointSize: 24
    44. }
    45.  
    46. Row {
    47. id: buttonRow
    48. anchors.bottom: parent.bottom
    49. anchors.horizontalCenter: parent.horizontalCenter
    50. anchors.bottomMargin: 20
    51. spacing: 20
    52.  
    53. Button { //Button is not a type
    54. id: plusButton
    55. operation: "+"
    56. onClicked: result.text = parseFloat(argument1.text) + parseFloat(argument2.text)
    57. }
    58.  
    59. Button {
    60. id: minusButton
    61. operation: "-"
    62. onClicked: result.text = parseFloat(argument1.text) - parseFloat(argument2.text)
    63. }
    64.  
    65. Button {
    66. id: timesButton
    67. operation: "*"
    68. onClicked: result.text = parseFloat(argument1.text) * parseFloat(argument2.text)
    69. }
    70.  
    71. Button {
    72. id: divideButton
    73. operation: "/"
    74. onClicked: result.text = parseFloat(argument1.text) / parseFloat(argument2.text)
    75. }
    76.  
    77. }
    78.  
    79. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: View possible in the design mode and qmlscene but not at the end or"run"

    Is your file named "button.qml" or "Button.qml"? Makes a difference, you know.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

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

    Default Re: View possible in the design mode and qmlscene but not at the end or"run"

    The name of the file : button.qml Thank you very much for your reply

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: View possible in the design mode and qmlscene but not at the end or"run"

    Well then, QML is going to be looking for a type named "button", not "Button". Rename your file to be consistent with QML conventions.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

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

    Default Re: View possible in the design mode and qmlscene but not at the end or"run"

    I deleted button.qml and then added Button.qml. There was an error of mine, but the application Output is now:
    Starting /home/sylvain/build-QtQuickCalculator-Qt_5_5_1_in_PATH_qt5_invalid-Debug/QtQuickCalculator...
    QML debugging is enabled. Only use this in a safe environment.
    For the views unfortunately they are the same as before. We must find another error. Thanks

  6. #6
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: View possible in the design mode and qmlscene but not at the end or"run"

    I don't know what else you are doing wrong, but in Button.qml, you are importing QtQuick 2.0, and in main.qml you are importing QtQuick 2.3. If you are writing your own code, then you should import the same version everywhere to ensure there aren't any conflicts.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

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

    Default Re: View possible in the design mode and qmlscene but not at the end or"run"

    I put QtQuick 2.5 in the two files. Same results. It is really very strange that last year, with O.S Linux 14.4 this worked well. Now with my 16.4 it doesn't. It looks as if a plugin is missing. Isn't it ? ?


    Added after 54 minutes:


    There is a difference between the Design picture on my book (in the Library it writes about Items) while in the Design picture of my screen it speeks of QML Types.
    Last edited by sylas; 24th December 2016 at 07:10.

  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: View possible in the design mode and qmlscene but not at the end or"run"

    Quote Originally Posted by sylas View Post
    I deleted button.qml and then added Button.qml. There was an error of mine, but the application Output is now:
    Starting /home/sylvain/build-QtQuickCalculator-Qt_5_5_1_in_PATH_qt5_invalid-Debug/QtQuickCalculator...
    QML debugging is enabled. Only use this in a safe environment.
    For the views unfortunately they are the same as before. We must find another error. Thanks
    There is no error and you have not provided any description of what is wrong.

    Quote Originally Posted by d_stranz View Post
    I don't know what else you are doing wrong, but in Button.qml, you are importing QtQuick 2.0, and in main.qml you are importing QtQuick 2.3. If you are writing your own code, then you should import the same version everywhere to ensure there aren't any conflicts.
    That shouldn't matter, otherwise one would have to constantly update ones files.

    Cheers,
    _

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

    Default Re: View possible in the design mode and qmlscene but not at the end or"run"

    I repeat. This calculator, last year, worked very well. Since I changed my O.S., I lost it, and now impossible to realize it. The big difference between the screenshot of my book and the picture I have on my screen is: Library shows "items" on my book and on my screen library speeks of QML. Here I send you a little screenshot of my screen:
    [ATTACHCONFIG]12264[/ATTACH]
    Attached Images Attached Images

  10. #10
    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: View possible in the design mode and qmlscene but not at the end or"run"

    Since you've started a new thread and wasted all context, there is nothing to even guess why it is not working elsewhere.

    Apparently you have a program that starts fine given the application output you've posted.

    Not sure what the screenshot of the QtQuick designer should tell us, but you've said the QML files work with qmlscene, so they should be ok.

    Cheers,
    _

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

    Default Re: View possible in the design mode and qmlscene but not at the end or"run"

    The only thing I can try now is to delete my QCreator and install a new one. I remind you that after my new O.S., Quick did not work with new QCreator I installed from Ubuntu Software Center. Someone of your forum indicated me to install qtdeclarative5-dev and qml-module-qtquick2. After that quick projects became possible.
    So you are the only one who can indicate me what complete QtCreator I must install. I am Linux user (O.S. 16.04) and I prefer use my terminal for installing.
    Must I uninstall the two little "plugings" too, before I install my new QtCreator, I hope you will indicate to me. Thank you very much. Cheers

  12. #12
    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: View possible in the design mode and qmlscene but not at the end or"run"

    If qmlscene works it is unlikely that there is something missing in the installation.

    Also your program runs without error, again an indication that the installation is ok.

    You have given no indication of what the problem is.

    Cheers,
    _

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

    Default Re: View possible in the design mode and qmlscene but not at the end or"run"

    The problem is that last year, with the ancient O.S. the calculator appeared at the end of "run". To-day no. I give below below the code of main.cpp. Maybe that there is the solution:
    Qt Code:
    1. //main.cpp
    2. #include <QGuiApplication>//origin
    3. //#include <QQmlEngine>
    4. //#include <QQuickImageProvider>
    5. //#include <QImageWriter>
    6. //#include <QAccessiblePlugin>
    7. #include <QQmlApplicationEngine>//origin
    8.  
    9. int main(int argc, char *argv[])
    10. {
    11. QGuiApplication app(argc, argv);//origin
    12. //QQmlEngine app(argc, argv);
    13.  
    14. QQmlApplicationEngine engine;//origin
    15. engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
    16.  
    17. return app.exec();
    18. }
    To copy to clipboard, switch view to plain text mode 

  14. #14
    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: View possible in the design mode and qmlscene but not at the end or"run"

    You are using a QQmlApplicaiton engine, yet your top level QtQuick element is not a Window.

    Seems like you took QML code from a QQuickView based program and mixed it with a QQmlEngine based main.

    I highly doubt that worked with any previous Qt version.

    Cheers,
    _

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

    Default Re: View possible in the design mode and qmlscene but not at the end or"run"

    So the error is in main.cpp. You should be very kind to rectify that code, and inform me. Unfortunately I am not experienced enough with Qt quick. Many thanks
    Cheers

  16. #16
    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: View possible in the design mode and qmlscene but not at the end or"run"

    Didn't one of your postings in one of the other threads already have the code for QQuickView?

    Cheers,
    _

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

    Default Re: View possible in the design mode and qmlscene but not at the end or"run"

    Even with the code of code-bundle I am unable to finish. It seems however so simple since the Design view is pretty well.. I give you the two codes (mine above, code from bundle below)
    Qt Code:
    1. //main.cpp
    2. #include <QtGui/QGuiApplication>
    3. int main(int argc, char *argv[])
    4. {
    5. QGuiApplication app(argc, argv);
    6.  
    7. QGuiApplicationViewer viewer;
    8. viewer.setMainQmlFile(QStringLiteral("qml/quick/main.qml"));
    9. viewer.showExpanded();
    10.  
    11. return app.exec();
    12. }
    13. /*
    14. //From code bundle
    15. #include <QtGui/QGuiApplication>
    16. #include "qtquick2applicationviewer.h"
    17. int main(int argc, char *argv[])
    18. {
    19.   QGuiApplication app(argc, argv);
    20.   QtQuick2ApplicationViewer viewer;
    21.   viewer.setMainQmlFile(QStringLiteral("qml/QtQuickCalculator/main.qml"));
    22.   viewer.showExpanded();
    23.  
    24.   return app.exec();
    25. }
    26. */
    To copy to clipboard, switch view to plain text mode 

  18. #18
    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: View possible in the design mode and qmlscene but not at the end or"run"

    How on earth is this related to the previous code?

    Are you just randomly posting code?

    Cheers,
    _

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

    Default Re: View possible in the design mode and qmlscene but not at the end or"run"

    What a relief*! Yesterday I saw the calculator at the end of «*run*». At first I deleted my Qt Creator of Ubuntu Software Center and I replaced it by the Qt Creator I got via the terminal. I have two projects (quick and QtQuickCalculator). The last has 3 files more than the other*: qtquick2applicationviewer.h , same name with .cpp, same name with .pri. It is this big project that works well. The only error it had is the path in the line*:
    viewer.setMainQmlfile(QStringLiteral(«*/home/sylvain/QtQuickCalculator/main.qml*»))*;
    I think the short project «*quick*» will work well if we put the calculator inside a button or window, exactly as does qmlscene. If you help me I think we will make that »quick*» project work as well as the other big project*!

Similar Threads

  1. Portable qt5.4 but "no qmlscene installed"
    By manceb in forum Installation and Deployment
    Replies: 2
    Last Post: 16th April 2016, 22:01
  2. Replies: 1
    Last Post: 20th November 2015, 10:02
  3. Replies: 3
    Last Post: 16th March 2015, 07:31
  4. "Cannot find -lqjpeg" error when compiling QT application in static mode
    By JonathanReez in forum Installation and Deployment
    Replies: 7
    Last Post: 6th September 2011, 15:44
  5. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 19:05

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.