Ask / Submit
2

Code issue: Button Icon - "source" is not a member of "". (M18) | "i" is declared more than once. (M107)

asked 2019-02-06 09:18:38 +0200

ds2k5 gravatar image

updated 2019-02-06 13:23:48 +0200

jiit gravatar image

Hello, can you help with coding problems too ? Sorry I am a noob in coding.... Try to modify a git project for the new SDK 1.24

Sailfish OS SDK 1.24

import QtQuick 2.2
import Sailfish.Silica 1.0
..
...

IconButton {
id: sendButton
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.bottomMargin: Theme.paddingLarge
icon.source: "image://theme/icon-m-enter-accept"   **"source" is not a member of "". (M18)**

tyed this:

IconButton.icon: "image://theme/icon-m-enter-accept"

or

icon: "image://theme/icon-m-enter-accept"

but this did not work.... got this error from app output:

[W] modifyPageStack:113 - Error while modifying page stack: Error: Error while loading page: file:///usr/share/projekt123/qml/pages/ChatPage.qml:40 Non-existent attached object

[D] onError:208 - ERROR: file:///usr/lib/qt5/qml/Sailfish/Silica/PageStack.js:483: Error: Error while loading page: file:///usr/share/project123/qml/pages/ChatPage.qml:40 Non-existent attached object

./SailfishOS/mersdk/targets/SailfishOS-3.0.1.11-i486/usr/lib/qt5/qml/Sailfish/Silica/PageStack.js

481 if (pageComp) {
482 if (pageComp.status == Component.Error) {
483 throw new Error("Error while loading page: " + pageComp.errorString())
484 } else {
485 // instantiate page from component
486 page = pageComp.createObject(container, properties || {})
487 }

another issue:

function stringToColour(str) {
var hash = 0;
for (var i = 0; i < str.length; i++) {
hash = str.charCodeAt(i) + ((hash << 5) - hash);
}
var colour = '#';
for (var i = 0; i < 3; i++) {                                                   **"i" is declared more than once. (M107)**
var value = (hash >> (i * 8)) & 0xFF;
colour += ('00' + value.toString(16)).substr(-2);
}
return colour;
}

How to fix this ?

edit retag flag offensive close delete

Comments

Ignore it, it still works despite the warnings. If you wish to suppress the message, hover over the underlined text and right click, select Refactoring / Add a comment to suppress this message - compile the app and see it working. Without seeing the rest of your code, it's really difficult to say why.

Also, please try to keep issues separate instead of lumping them altogether in one post.

Edz ( 2019-02-06 15:37:13 +0200 )edit

2 Answers

Sort by » oldest newest most voted
1

answered 2019-02-11 01:47:33 +0200

Direc gravatar image

updated 2019-02-11 01:56:12 +0200

I just ran into this, so I took a look at it. It looks like IconImage contain HighlightImage element internally, which would inherit from HighlightImageBase, but there is no such file in the SDK, so the chain breaks and an error is shown. The solution would be to add the missing file, but Jolla has to do that.

If you really want to workaround it (like I did), add line property string source on the SDK to ~/SailfishOS/mersdk/targets/SailfishOS-[version]-[arch]/usr/lib/qt5/qml/Sailfish/Silica/IconButton.qml. It doesn't affect the emulator or compiling, but it gets rid of the message, as QtCreator is now aware enough of such property.

As usual, don't modify the SDK files if you don't know what you are doing.

Do not edit the file on the device! It may/will break the system. This trick is for SDK only!

Edit: The "i" is declared more than once error is JavaScript behaviour, and you could get rid of the message in a few ways:

  • Declare i before the first for loop, and use for(i = 0; ... instead
  • Use i in first for loop, and ´j´ in the second
  • Wait until Sailfish uses Qt 5.12 and use let instead of var (introduced in ECMAScript 2015, see QTBUG-47735 for details)
edit flag offensive delete publish link more
0

answered 2019-02-06 14:52:15 +0200

icon.source is the correct definition, if I remember correctly import Sailfish.Media 1.0 may fix the icon issue (not sure if harbour allows it though)

On the colour, are you trying to convert it to RGB or something? I'd be surprised if QColor::convertTo can't do that or you.

edit flag offensive delete publish link more

Comments

Add import statement Sailfish.Media is not relevant.

Edz ( 2019-02-06 15:37:25 +0200 )edit
Login/Signup to Answer

Question tools

Follow
2 followers

Stats

Asked: 2019-02-06 09:18:38 +0200

Seen: 193 times

Last updated: Feb 11