Results 1 to 5 of 5

Thread: QFileDialog single click only

  1. #1
    Join Date
    May 2011
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QFileDialog single click only

    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.

    Qt Code:
    1. QFileDialog* fd = new QFileDialog(this, fdcapt, textdir );
    2. fd->setObjectName("fileopendialog");
    3. fd->setViewMode(QFileDialog::List);
    4. fd->setFileMode( QFileDialog::ExistingFile );
    5. fd->setAcceptMode(QFileDialog::AcceptOpen);
    To copy to clipboard, switch view to plain text mode 

    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
    Last edited by alxobr; 30th April 2012 at 18:29.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QFileDialog single click only

    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:
    Qt Code:
    1. #include <QtGui>
    2. #include <QDebug>
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication app(argc, argv);
    7.  
    8. QString fdcapt = QObject::tr("File dialog caption");
    9. QString textdir(".");
    10.  
    11. // That's your code without the heap allocation
    12. QFileDialog fd(0, fdcapt, textdir );
    13. fd.setObjectName("fileopendialog");
    14. fd.setViewMode(QFileDialog::List);
    15. fd.setFileMode( QFileDialog::ExistingFile );
    16. fd.setAcceptMode(QFileDialog::AcceptOpen);
    17.  
    18. qDebug() << fd.exec();
    19. qDebug() << fd.selectedFiles();
    20.  
    21. return 0;
    22. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    May 2011
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QFileDialog single click only

    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
    Last edited by alxobr; 1st May 2012 at 15:07.

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QFileDialog single click only

    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.

  5. #5
    Join Date
    Dec 2010
    Posts
    3
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QFileDialog single click only

    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

Similar Threads

  1. Replies: 7
    Last Post: 26th April 2012, 14:45
  2. Replies: 2
    Last Post: 28th November 2011, 15:12
  3. Replies: 1
    Last Post: 7th May 2011, 20:24
  4. Replies: 6
    Last Post: 5th June 2009, 09:38
  5. Replies: 2
    Last Post: 11th January 2009, 23:24

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.