Results 1 to 16 of 16

Thread: DontUseNativeDialog option and non-static functions

  1. #1
    Join Date
    Jun 2010
    Posts
    6
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default DontUseNativeDialog option and non-static functions

    When I create a file dialog using a static function from QFileDialog the DontUseNativeDialog option can be enabled or or disabled. But if I create a file dialog using the constructor that option is enabled no matter what I do. Even when testOption(QFileDialog::DontUseNativeDialog) returns false. Is there something related I miss?
    Thanks

  2. #2
    Join Date
    Jan 2009
    Posts
    47
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: DontUseNativeDialog option and non-static functions

    I experience the same problem of not being to force a native dialog on Windows when using the QFileDialog constructor. Can someone help?

  3. #3
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: DontUseNativeDialog option and non-static functions

    If you create a QFileDialog subclass, this is documented behavior:
    the native file dialog is used unless you use a subclass of QFileDialog that contains the Q_OBJECT macro.
    Is this the case?

  4. #4
    Join Date
    Jan 2009
    Posts
    47
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: DontUseNativeDialog option and non-static functions

    No, it isn't. I use the QFileDialog constructor isntead of the static ones (because I have the need to use the setHistory etc ...).

  5. #5
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: DontUseNativeDialog option and non-static functions

    Quote Originally Posted by ttvo View Post
    No, it isn't. I use the QFileDialog constructor isntead of the static ones (because I have the need to use the setHistory etc ...).
    Okidoki, I didn't know I need to use a static function to create a subclass. I did learn something new, thanks.

    First of all, the meaning of DontUseNativeDialog is understood correctly? When true, it does not show the native dialog, when false is does.
    If so, can you please provide a small compilable example of the problem so I can test some things out on my computer?

  6. #6
    Join Date
    Jan 2009
    Posts
    47
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: DontUseNativeDialog option and non-static functions

    Code where the windows native dialog is NOT used and can't find any flags to enable that
    Qt Code:
    1. QFileDialog dialog(this);
    2. dialog.setFileMode(QFileDialog::AnyFile);
    3. dialog.setHistory("list of my custom path histories");
    4. dialog.exec();
    To copy to clipboard, switch view to plain text mode 

    when using the static calls, of course, the native dialog is used, but then I can't setHistory etc ...

    Thx

  7. #7
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: DontUseNativeDialog option and non-static functions

    Quote Originally Posted by ttvo View Post
    and can't find any flags to enable that
    Did you try:
    Qt Code:
    1. dialog.setOption(QFileDialog::DontUseNativeDialog, false);
    To copy to clipboard, switch view to plain text mode 
    ?

  8. #8
    Join Date
    Jun 2010
    Posts
    6
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: DontUseNativeDialog option and non-static functions

    @ tbscope: Did you?

  9. #9
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: DontUseNativeDialog option and non-static functions

    Quote Originally Posted by Qtbl View Post
    @ tbscope: Did you?
    No, it is a simple question for you or the other poster. Answer it with any of the following please:
    1. Yes, but it still doesn't work.
    2. Yes, and now it works.
    3. No.

    A: Help my car doesn't start.
    B: Did you try to turn it on?
    A: Did you?
    Edit:
    Yes, I tried it.

    Qt Code:
    1. QFileDialog dlg(this);
    2.  
    3. dlg.exec();
    To copy to clipboard, switch view to plain text mode 
    This shows the native dialog in KDE.

    Qt Code:
    1. QFileDialog dlg(this);
    2.  
    3. dlg.setOption(QFileDialog::DontUseNativeDialog, true);
    4. dlg.exec();
    To copy to clipboard, switch view to plain text mode 
    This shows the Qt file dialog in KDE.

    Qt Code:
    1. QFileDialog dlg(this);
    2.  
    3. dlg.setOption(QFileDialog::DontUseNativeDialog, false);
    4. dlg.exec();
    To copy to clipboard, switch view to plain text mode 
    This shows the native KDE dialog
    Last edited by tbscope; 28th September 2010 at 07:49.

  10. #10
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: DontUseNativeDialog option and non-static functions

    Quote Originally Posted by tbscope View Post
    A: Help my car doesn't start.
    B: Did you try to turn it on?
    A: Did you?
    oh man!! .. ROTFL

  11. #11
    Join Date
    Jun 2010
    Posts
    6
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: DontUseNativeDialog option and non-static functions

    If you want to help us just do it. Don't BS us with deep truisms:
    Quote Originally Posted by tbscope View Post
    ... First of all, the meaning of DontUseNativeDialog is understood correctly? When true, it does not show the native dialog, when false is does.
    If you read my first post you'll notice that I have this situation: the file dialog created using a constructor is the one Qt provides even when DontUseNativeDialog is disabled - set to false using setOption (when testOption(QFileDialog::DontUseNativeDialog) returns false).

    Glad to hear it works on your system. Does this help me? Nope

    LE:
    @ MrDeath: Dude, don't interrupt a small talk, try Cartoon Network instead
    Last edited by Qtbl; 28th September 2010 at 09:47.

  12. #12
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: DontUseNativeDialog option and non-static functions

    Can you show your sample code please. how you are setting the option? The last code u pasted, did not set that option.

  13. #13
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: DontUseNativeDialog option and non-static functions

    Qtbl,

    Can you please post a small compilable example so I can test it on my computer?
    That you already set that option explicitly was not clear to me.

    What operating system do you use?

  14. #14
    Join Date
    Jun 2010
    Posts
    6
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: DontUseNativeDialog option and non-static functions

    FileDialogTest.pro
    Qt Code:
    1. QT += gui
    2.  
    3. TEMPLATE = app
    4. TARGET = FileDialogTest
    5.  
    6. HEADERS += FileDialogTest.h
    7. SOURCES += main.cpp
    To copy to clipboard, switch view to plain text mode 

    main.cpp
    Qt Code:
    1. #include <QApplication>
    2. #include "FileDialogTest.h"
    3.  
    4. int main(int argc, char* argv[])
    5. {
    6. QApplication app(argc, argv);
    7. FileDialogTest fileDialogTest;
    8.  
    9. fileDialogTest.show();
    10.  
    11. return app.exec();
    12. }
    To copy to clipboard, switch view to plain text mode 

    FileDialogTest.h
    Qt Code:
    1. #ifndef FILE_DIALOG_TEST
    2. #define FILE_DIALOG_TEST
    3.  
    4. #include <QDialog>
    5. #include <QFileDialog>
    6. #include <QVBoxLayout>
    7. #include <QPushButton>
    8. #include <QLabel>
    9. #include <QCheckBox>
    10.  
    11. class FileDialogTest : public QDialog
    12. {
    13. Q_OBJECT
    14.  
    15. public:
    16. FileDialogTest(QWidget* parent = 0) : QDialog(parent)
    17. {
    18. QVBoxLayout* main_layout = new QVBoxLayout(this);
    19. QPushButton* createFileDialog_btn = new QPushButton("Open file");
    20. useNativeDialog = new QCheckBox("Use native dialog");
    21. dialogType = new QLabel("DontUseNativeDialog = ?");
    22.  
    23. connect(createFileDialog_btn, SIGNAL(clicked()), this, SLOT(createFileDialog()));
    24.  
    25. main_layout->addWidget(createFileDialog_btn);
    26. main_layout->addWidget(useNativeDialog);
    27. main_layout->addWidget(dialogType);
    28. }
    29.  
    30. private slots:
    31. void createFileDialog()
    32. {
    33. QFileDialog dialog(this);
    34.  
    35. dialog.setOption(QFileDialog::ShowDirsOnly);
    36. if (useNativeDialog->isChecked())
    37. dialog.setOption(QFileDialog::DontUseNativeDialog, false);
    38. else
    39. dialog.setOption(QFileDialog::DontUseNativeDialog, true);
    40.  
    41. dialogType->setText(QString("DontUseNativeDialog = %1").arg(dialog.testOption(QFileDialog::DontUseNativeDialog)));
    42.  
    43. dialog.exec();
    44. }
    45.  
    46. private:
    47. QCheckBox* useNativeDialog;
    48. QLabel* dialogType;
    49. };
    50.  
    51. #endif // FILE_DIALOG_TEST
    To copy to clipboard, switch view to plain text mode 

    On my system (Windows XP SP3) the type of the dialog is the same - Qt file dialog - even though in the first case (default, when the state of the checkbox is unchecked) the label shows 1 and in the second it shows 0.
    So what's wrong with this code? (Remember, I'm a newbie)

  15. #15
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: DontUseNativeDialog option and non-static functions

    I did some testing and reading.

    This DOES work on Linux. It does NOT work on Windows XP
    This means there's an inconsistency. This alone is worth a bug report.

    Edit: Just to note that I've found a reply of the person who maintains QFileDialog and according to him:

    Since 4.5 on the mac if you use the class QFileDialog (not static functions), it will display the native Mac dialog unless you give the flag QFileDialog::DontUseNativeDialog. Unfortunately this feature is not implemented for Windows. The only way to get the native dialog on Windows is static functions. Of course you have no control on the native one. So, why not using the Qt one instead?
    Last edited by tbscope; 28th September 2010 at 11:52.

  16. The following user says thank you to tbscope for this useful post:

    Qtbl (28th September 2010)

  17. #16
    Join Date
    Jun 2010
    Posts
    6
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: DontUseNativeDialog option and non-static functions

    Oh, I see. Thanks for the info.

Similar Threads

  1. C++ Static Functions
    By weaver4 in forum Newbie
    Replies: 7
    Last Post: 17th November 2009, 10:42
  2. Remove Help option
    By bismitapadhy in forum Qt Programming
    Replies: 4
    Last Post: 15th June 2009, 13:23
  3. Replies: 2
    Last Post: 16th March 2007, 09:04
  4. rtti option
    By sar_van81 in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 5th January 2007, 15:10
  5. Static functions and class members
    By Raistlin in forum General Programming
    Replies: 5
    Last Post: 22nd December 2006, 10:00

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.