larray-project / larray-editor

Graphical User Interface for LArray
GNU General Public License v3.0
2 stars 2 forks source link

Support loading "narrow" data using File->Open Data #245

Open gdementen opened 1 year ago

gdementen commented 1 year ago

We need to add a checkbox in the File dialog or something like that

gdementen commented 1 year ago

This does not seem as simple as I thought, unless we use some trickery.

Apparently, this is not supported anymore since Qt started its push to use system file dialogs where possible (in Qt4 it seems).

The only workaround I read about is to force using Qt builtin dialog instead of the system dialog by setting the QFileDialog::DontUseNativeDialog flag and then add our widget to the FileDialog manually.

Below is some C++ code doing that (from https://www.qtcentre.org/threads/42858-Creating-a-Custom-FileOpen-Dialog)

void FileDialog::addCheckBoxIn() {
    QDialogButtonBox *box = qFindChild<QDialogButtonBox*>(this);
    QBoxLayout *l = qFindChild<QBoxLayout*>(box);
    QCheckBox *toProj = new QCheckBox("To Project:", box);
    l->insertWidget(0, toProj);
}
gdementen commented 1 year ago

Another, uglier but easier solution is to select the file using the normal/system dialog but open a second dialog with options. Or we could open that "options" dialog directly and have the filepath one of the options.