Can I use a QMessagebox in plugin code?
I feel kind of silly asking this because it seems I should be able to figure this out for myself. But I haven't been able to either make it work or definitively determine it's impossible.
I simply wish to pop up a modal dialog box to inform the user if an error has been encountered. This is for a plugin that otherwise has no other user interface components. Meaning that I haven't created any windows. I don't need a user interface, other than informing of errors, so was hoping to be able to just pop up a message if needed.
If anyone can point me at a good .qml example that'd be awesome. OR alternatively inform me that I really will have to create a 'real' main UI window to do this.
In hunting around I've seen QMessagebox in some javascript used in some plugins; but have not found any examples in qml. My current best attempts have been (both fail):
import QtQuick 2.2
import QtQuick.Layouts 1.2
import QtQuick.Controls 1.0
import QtQuick.Dialogs 1.1
import MuseScore 3.0
MuseScore {
version: "1.0.0"
description: "Testing popup message boxes"
menuPath: "Plugins.Popup Message Box
onRun: {
var QMessageBox msgBox; // try this
// QMessageBox.critical("", "File Name", "-"); // and try this
Qt.quit();
}
Creating component failed
line 43: Unexpected token `identifier'
Comments
You should be able to use a MessageDialog which is for example used in the UltraStar Exporter plugin to show error messages.
In reply to You should be able to use a… by jeetee
Yes, that's too easy! Thanks much jeetee.
In reply to You should be able to use a… by jeetee
Does this version of the Ultrastar Exporter work with MS3.6? I downloaded it (hopefully as an example for doing dialogs) and noticed "import MuseScore 1.0", also "Latest commit on Mar 31, 2016".
In reply to Does this version of the… by dhfx
That one indeed won't.
In reply to Does this version of the… by dhfx
I used the below plugin's code to help me with windows and user interface widgets:
Expand chord symbols into notes