My first attempt at a plugin: PartsList.qml
So, I finally bit the bullet and tried to learn enough Qt to write a plugin. Simple plugin, it creates a text file that lists the parts in a score. Help me out with Version 2 where I'd like to fix/add:
1. Part names with flats (and I suppose sharps) in them show up as question marks in a text editor. I'd like to replace that with a word. But, even if I use QReplace, what do I tell it to replace?
2. On windows, the plugin opens the list in Notepad. There must be a way to determine the OS and then open it in an appropriate editor in other OS's. I'm guessing it will write OK in other OS's, but I don't have any installations to test it in.
Let me know what you think.
https://github.com/jasendorf/PartsList
John
Comments
Fixed an issue brought to my attention with using Qt.quit, moved code to github
So, I thought the following might fix my ? problem...
But, all that did is break it. Any suggestions are welcome.
In reply to So, I thought the following… by John Asendorf
It might be showing boxes for flats/sharps simply because Notepad uses a default font that doesn't include those symbols?
Consider opening your file with Notepad++ for example and verify its encoding (which would be "system default").
Alternatively, perform a plain javascript
String.replaceAll()
in qml firstIn reply to It might be showing boxes… by jeetee
Yeah, I've tried it in a bunch of editors but they all come back with question marks (not the dreaded boxes). So, I'm thinking I actually have question marks meaning that I need to tell Qt what they are or what encoding they're in.
I know how to replace... I just don't know WHAT to tell it to replace.
In reply to Yeah, I've tried it in a… by John Asendorf
Wouldn't it possibly work by copy-pasting the character from the instrument name? '♭' for example.
Otherwise you'll need to resort to the unicode of those symbols.
In reply to Yeah, I've tried it in a… by John Asendorf
Internally
QTextStream
is used in FileIO implementation, and QTextStream documentation has the following statement regarding text encoding:Given this, may the issue be in that
QTextStream
chooses a non-Unicode codec by default on Windows, and this results in most non-ASCII characters be written incorrectly? If so it might be needed to explicitly set the stream codec to UTF-8 or at least expose an ability to set encoding of the written text toFileIO
interface.I am not on Windows to check this but perhaps someone could verify my guess there.
For the OS-dependency, you can use
(Qt.platform.os=="windows")
for example