general info on QT as it relates to MuseScore plugins?

• Jun 19, 2011 - 20:26

I've got a few plugins in the works. At least one would involve creating a dialog box / GUI, but that task is a bit a daunting to me, not being familiar with QT. I'm trying to crib what I can from other plugins, but am wondering if there are specific resources I should be checking out for info. There is, needless to say, an overwhelming amount of info on QT in general, but I'm trying to figure out what I actually need - and can access - for creating some basic dialog boxes.


Comments

You can almost access any class of the Qt Framework. (note that it's Qt not QT).
The easiest way to make a dialog or UI is to use Qt Creator. Qt Creator is installed with your version of Qt normally.

  1. Open Qt Creator
  2. File -> New File or Project -> Qt -> Qt Designer Form
  3. Create your form with the graphic interface. You may want to learn more about Layout Management in Qt
  4. Save your file as for example my.ui
  5. In your script use the following lines

    //read the UI file and create a form out of it
    var loader = new QUiLoader(null);
    var file = new QFile(pluginPath + "/my.ui");
    file.open(QIODevice.OpenMode(QIODevice.ReadOnly, QIODevice.Text));
    form = loader.load(file, null);

    //initialize some widget value if necessary
    form.verticalLayoutWidget.myLabel.text = curScore.title;
    form.verticalLayoutWidget.myLabel2.text = curScore.composer;

    //connect signal
    form.searchBtn.clicked.connect(doSomething);
    form.closeBtn.clicked.connect(close);

    //show the form
    form.show();

  6. Signals and slots are a Qt concept. When a signal is fired (for example with a button is clicked), slots connected to it are executed. Slots can be define in your script to do something when something happens in the interface

The "break" plugin is a good and simple example of this process. Should I put this in the plugin documentation? An idea for a title?

In reply to by [DELETED] 5

Thanks for the info, and yes, I think this would be good for the plugin docs. "Creating a GUI using Qt" would make a nice title.

I had uninstalled Qt in anticipation of setting up a build environment on an external drive, but this may be the incentive I need to re-install it.

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