Can I use a QMessagebox in plugin code?

• Feb 12, 2021 - 16:35

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

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