Error Cannot Assign Undefined To Qstring
download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript). Home Qt Development QML and Qt Quick [SOLVED]Q_PROPERTY QString linking qml and c++ giving "undefined" error [SOLVED]Q_PROPERTY QString linking qml and c++ giving "undefined" error This topic has been deleted. Only users with topic management privileges can see it. Billcode last edited by This simple example should test the linking between QObject class property and qml. A string from TextInput should get displayed in a Rectangle on a mouse click. Instead, an error - Cannot assign [undefined] to QString - is delivered. Could anyonw help? @//mainwindow.h #ifndef MAINWINDOW_H #define MAINWINDOW_H #include
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 https://forum.qt.io/topic/26464/solved-q_property-qstring-linking-qml-and-c-giving-undefined-error million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up 'Error: Cannot assign [undefined] to QString' in FolderListModel on Component.onCompleted in QML up vote 0 down vote favorite ScrollView { id: scrollViewHead height: 400; width: 400 frameVisible: true Image { id: currentPicture height: 400; width: 400 source: http://stackoverflow.com/questions/33034066/error-cannot-assign-undefined-to-qstring-in-folderlistmodel-on-component-on folderModel.fetchCurrentFileName z:0 } } FolderListModel { id: folderModel nameFilters: ["*.png"] folder: "file:///home/eeee/template" property int fetchIndex: -1 property string fetchCurrentFileName onFetchIndexChanged: { fetchCurrentFileName = get (fetchIndex, "fileName") } } Component.onCompleted: folderModel.fetchIndex = 0 This results in: Error: Cannot assign [undefined] to QString on the line which has the get method. The problem is that this code works fine when I click next button (which I have not shown here). That button increments folderModel.fetchIndex. But when I increment folderModel.fetchIndex through Component.onCompleted: that error gets shown. P.S. Folder in question does have images. Please guide. qt qml qtquick2 share|improve this question asked Oct 9 '15 at 8:59 Aquarius TheGirl 4,75827105204 2 I think it would be much easier to jump into understanding the problem if it was a minimal, complete example. The nature of the question seems to imply that scope is important, as well, so it would help if we had the whole picture. –Mitch Oct 9 '15 at 10:32 1 @M
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more http://stackoverflow.com/questions/37951575/qml-unable-to-assign-undefined-to-qstring about Stack Overflow the company Business Learn more about hiring developers or posting https://bugs.kde.org/show_bug.cgi?id=335067 ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up QML unable to assign undefined to qstring up vote 0 down error cannot vote favorite I'm trying to append an image to listview dynamically. If I do it using ListElement and specifying the path statically , it works but if I try to do it using FileDialog.fileUrl.toString() in the onAccepted event, it throws the error I mentioned in the title. The file URL gets printed successfully on console though. Here's the relevant code: FileDialog { id: aImage title: "Please choose a file" error cannot assign folder: shortcuts.pictures nameFilters: [ "Image files (*.jpg *.png)", "All files (*)" ] onAccepted: { console.log("You chose: " + aImage.fileUrl.toString()) listModel.append({username: "Akash", src: aImage.fileUrl.toString()}); listView.positionViewAtEnd(); } } Here is the Image element of the ListView's item delegate: Image{ id: image height: 50 width: 50 source: src Component.onCompleted: console.log("src: " + src); } qml share|improve this question asked Jun 21 at 18:08 Akash Aggarwal 639525 Works fine (and there's nothing wrong with the posted code). Probably the relevant part is missing. Please, try to provide a full working example. –BaCaRoZzo Jun 22 at 7:26 @BaCaRoZzo thanks for replying. Can you please post the code you tested with? I've cross checked it and this is the most relevant code that anyone needs to see. –Akash Aggarwal Jun 22 at 14:02 @BaCaRoZzo Strange enough, I did some suspicious changes. It worked. But now that I've commented those changes, it works as well as it should. –Akash Aggarwal Jun 22 at 14:07 That's why I always push for complete working examples: it's a way to shrink the problem to a minimum, focus and, sometimes, find the solution yourself. :) Glad you solved. That was probably not related to the posted code. –BaC
Unable to assign [undefined] to QString Status RESOLVED FIXED Product: krunner Classification: Unclassified Component: general Version: unspecified Platform: Gentoo Packages Linux Importance: NOR normal (vote) TargetMilestone: --- Assigned To: Plasma Bugs List URL: Keywords: Depends on: Blocks: Show dependency tree /graph Reported: 2014-05-20 09:20 UTC by Elias Probst Modified: 2014-05-23 15:11 UTC (History) CC List: 1 user (show) me See Also: Latest Commit: http://commits.kde.org/milou/c500e2d3962c950b88854dd1fad51858ea0a1557 Version Fixed In: Description Elias Probst 2014-05-20 09:20:14 UTC Typing something in krunner repeatedly shows these two messages in its log output: file:///usr/lib64/qml/org/kde/milou/ResultDelegate.qml:72:16: Unable to assign [undefined] to QString file:///usr/lib64/qml/org/kde/milou/ResultDelegate.qml:111:19: Unable to assign [undefined] to QString Running latest KF5/PlasmaNext from git. Comment 1 Elias Probst 2014-05-20 09:21:55 UTC Just noticed, this should be actually reported against Milou, but I can't reassign since there's no Milou product yet. @vHanda: That's something for you, right? Comment 2 Vishesh Handa 2014-05-23 15:11:00 UTC Git commit c500e2d3962c950b88854dd1fad51858ea0a1557 by Vishesh Handa. Committed on 23/05/2014 at 15:17. Pushed by vhanda into branch 'frameworks'. ResultDelegate: Always convert the text into strings Otherwise we get errors where undefined cannot be assinged to a QString because QML is stupid and does not autoconvert it. Or maybe not, and I cannot figure out what is going on. M +2 -7 lib/qml/ResultDelegate.qml http://commits.kde.org/milou/c500e2d3962c950b88854dd1fad51858ea0a1557 Attachments Add an attachment (proposed patch, testcase, etc.) Note You need to log in before you can comment on or make changes to this bug. Format For Printing -XML -Clone This Bug -Top of page This bug is not in your last search results. KDE Links Home KDE's Code of Conduct Saved Searches Reports Bugs reported today Bugs reported in the last 3 days Bug reports with patches Weekly Bug statistics Most hated bugs Most seve