Property variant limit?

• Oct 21, 2018 - 03:17


I have some code that will not run if I add any more than 4 property variant arrays of the dimension 4 x 3. I am wondering if there is a limit to the property variant elements or if there is some way to get around this issue?
My goal is to add 13 total arrays as property variants in the initial portion of the documentation.

Thank you!


I'm not aware of any such limit. Are you using declarations of the following form?

property variant foo: // etc

If so, try replacing "variant" with "var". (See : "The variant type is a generic property type. It is obsolete and exists only to support old applications; new applications should use var type properties instead.") Although I doubt this will resolve your issue.

If you provide more info or a snippet of your code we might be able to help more.

In reply to by PaulSC

Thank you so much for your willingness to help!

I changed the declarations to "var", which does seem like good practice. Thank you for that suggestion, however it does not resolve the issue, as you had already expected. Here is a code snippet, maybe I am missing something.

import QtQuick 2.0
import MuseScore 1.0

MuseScore {
version: "1.0"
description: "This demo plugin colors notes in the selection depending on pitch, matched to SolJAMM colors"
menuPath: "Plugins.Notes.SolJAMMKeycolors"

  property var colorsC : [
           "#ff0000", "#000000", "#ffaa00",
           "#000000", "#ffff00", "#00bb00",
           "#000000", "#0000ff", "#000000",
           "#b400d0", "#000000", "#969696"

  property var colorsCSh : [
           "#969696", "#ff0000", "#000000", 
           "#ffaa00", "#000000", "#ffff00", 
           "#00bb00", "#000000", "#0000ff", 
           "#000000", "#b400d0", "#000000", 

  property var colorsD : [
           "#000000", "#969696", "#ff0000",  
           "#000000", "#ffaa00", "#000000",  
           "#ffff00", "#00bb00", "#000000",  
           "#0000ff", "#000000", "#b400d0", 

property var colorsDSh : [
"#b400d0", "#000000", "#969696"
"#ff0000", "#000000", "#ffaa00",
"#000000", "#ffff00", "#00bb00",
"#000000", "#0000ff", "#000000",
// etc.. for 8 more arrays
property var black : "#000000"

I call these variables using:

function colorKey(note){

        if (curScore.keysig == 0)//C
            note.color = colorsC[note.pitch % 12 ];

       if  (curScore.keysig == 1)//G
             note.color = colorsG[note.pitch % 12];

// etc.. addressing all property variants

If I uncomment any more than 4 property variant arrays the code will not run.
Please let me know if you would like me to provide anything else.

Any thoughts?
Many thanks!

In reply to by PaulSC

Yes! It is now working, thank you so much!

I love it when that happens. I really appreciate you taking a second look.
Out of curiosity, what QML editor are you using to debug your code? I haven't seen any error messages in the Plugin creator provided by MuseScore.

In reply to by soljamm

I'm glad your plugin is running!

I use MuseScore's built-in editor. It should give you a console view below the text-editor. See the attached screenshot. If your view is different, try dragging the bar below the editor to resize the editor and console frames. (Or maybe this feature is platform-dependent? I'm on Windows 8.1 fwiw.)

Attachment Size
deBug.PNG 52.87 KB

Do you still have an unanswered question? Please log in first to post your question.