PDA

View Full Version : QFileDialog single click only



alxobr
30th April 2012, 19:24
Hi all,

I cannot get rid of the single click Open File behavior on Qt 4.7 X11.
I thought there might be a new option and that the new default was single click but I could not find it in the doc.
I never ever chose such an option as single click open file behavior.


QFileDialog* fd = new QFileDialog(this, fdcapt, textdir );
fd->setObjectName("fileopendialog");
fd->setViewMode(QFileDialog::List);
fd->setFileMode( QFileDialog::ExistingFile );
fd->setAcceptMode(QFileDialog::AcceptOpen);

Qt linguist has also started to react like this, which I never noticed before. Of course it is much less indispensable than the icon zoom feature now found in the open file dialog :) but users might want to select a file without opening it.

Cheers,

Alexandre

ChrisW67
1st May 2012, 02:01
There is no "single click behavior" in the Qt 4.7 QFileDialog (or AFAICT in Linguist) whether I use the native (KDE) or generic dialog. This complete example works perfectly fine here:


#include <QtGui>
#include <QDebug>

int main(int argc, char *argv[])
{
QApplication app(argc, argv);

QString fdcapt = QObject::tr("File dialog caption");
QString textdir(".");

// That's your code without the heap allocation
QFileDialog fd(0, fdcapt, textdir );
fd.setObjectName("fileopendialog");
fd.setViewMode(QFileDialog::List);
fd.setFileMode( QFileDialog::ExistingFile );
fd.setAcceptMode(QFileDialog::AcceptOpen);

qDebug() << fd.exec();
qDebug() << fd.selectedFiles();

return 0;
}

alxobr
1st May 2012, 15:52
Thank you Chris for your help.

I compiled the example you gave and got the same behavior as with my program: the clicked file is opened instantly.

So I made some investigations and found that the culprit was KDE. Though I use icewm and not KDE as a desktop environment, I have KDE 4.5.2 installed. KDE 4.5.2 has a "single click" default behavior.

In case it helps someone, I could change this behavior by typing "systemsettings &" at a bash prompt and selecting Hardware > "Input devices" > Mouse > "Double-click to open files and folders (select icons on first click)". I then had to restart the affected applications to see the change.

This could be seen as a KDE bug, since it also impacts those Qt apps which are not KDE (GTK apps don't seem to be affected however).

Cheers,

Alexandre

ChrisW67
2nd May 2012, 07:03
Double-click has always been the default on KDE installs I have done (since 2.x). Perhaps someone has been trying to web-ify your desktop.

Qt will use the native file dialogs if they are available. It is definitely not a bug that a KDE dialog honours the KDE system settings. If you tell Qt not to use the native dialog then it falls back on a Qt internal dialog. On my system that also honours the KDE setting, something I did not expect. Whether you consider that a bug in Qt, I don't know.

iw2lsi
14th November 2012, 23:47
Hi

same problem here... using latest qt 4.8.3 on kubuntu 11.10

setting KDE to use double click to open files and folder does not solve the problem

Giampaolo