Resolve error in Qt Creator

In qml when you use certain types like Button or Icon a lot of errors like
m310 could not resolve prototype Private.HighlightImageBase (or SilicaMouseArea) shows up. The app still runs
but I dont understand where the type information is supposed to be in the qmldir ? And is there any workaround to avoid this warnings in the IDE ?

From Sailfish IDE qt creater docs: Various warnings are produced by the QML static code checker for Sailfish.Silica types with the build targets matching recent Sailfish OS releases, like Could not resolve the prototype “SilicaItem” of “PageHeader”. (M301)

Yep. same for most of us, but as you point out, you can still build and produce apps.

Not a workaround but a feature of the SDK, you can right click on the underlined component and select 'Refactoring and choose Add a comment to suppress this message by doing this you will see this comment // @disable-check M301` is placed above the component.

These are not really errors as such, just stuff that hasn’t been ironed out as SDK is updated, I think maybe this will be fixed in the next SDK release, but either way, keep building!

3 Likes

Thanks for the tip, this helps a good deal. Having the red lines throughout my code was a bit distracting, false alarms etc.

1 Like

Yes thanks Edz // @disable-check M301 works like a champ

1 Like

Alternatively, those who do not need to use the most recent Sailfish OS API additions can use build targets matching some older Sailfish OS release. These can be installed using the SDK Maintenance Tool (or with sfdk tools install) and then appear as additional Kits under Qt Creator. Unfortunately it is not trivial to make it support recent Sailfish Silica versions.

After updating the SDK earlier today, I’ve got every single qml file in the editor literally filled up with M301 warnings for Page, Button, PullDownMenu, PushUpMenu, MenuItem, Icon, and a lot more.

The // @disable-check M301 comment works for a single instance only, so I would need to add it to every warning, in every file.

Don’t they do even the most basic check prior to releasing an SDK update? Like just launching Qt creator and opening some project in it? If they did, they surely would have noticed it as even the Page type is affected, i.e. something really hard to go unnoticed.