Results 1 to 11 of 11

Thread: Wishing my windows build wasn't so windows like

  1. #1
    Join Date
    Feb 2007
    Posts
    29
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Wishing my windows build wasn't so windows like

    On Linux when you store settings, they're usually stored in a INI text file. On OSX when you store settings, they're usually stored in a XML text file. Is there any way to make my windows build use one of those methods for manipulating settings instead of the awful registry?

    On OSX when you go open up a QFileDialog::getOpenFileName the directory it starts in is set to the last directory you visited. Is there anyway to make my windows build behave like this? Preferably combining that with the text file settings mentioned above.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Wishing my windows build wasn't so windows like

    Pass IniFormat to a QSettings constructor variant that takes a format parameter.

    As for the other question, the dialog takes a path to its starting directory as an argument. Simply store the last used path in some QString and use it here.

  3. The following user says thank you to wysota for this useful post:

    scwizard (24th February 2007)

  4. #3
    Join Date
    Feb 2007
    Posts
    29
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Wishing my windows build wasn't so windows like

    Quote Originally Posted by wysota View Post
    Pass IniFormat to a QSettings constructor variant that takes a format parameter.
    I can't belive I missed that, I guess my look over the QSettings docs was too cursory.

    Quote Originally Posted by wysota View Post
    As for the other question, the dialog takes a path to its starting directory as an argument. Simply store the last used path in some QString and use it here.
    My problem at first is that I wasn't sure how to fetch the last used path because I was caught up in thinking that it was a function. But then I realized it should be constructed on the stack in the same manner as message boxes. I have an idea of how to do it now.

  5. #4
    Join Date
    Feb 2007
    Posts
    29
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Wishing my windows build wasn't so windows like

    OK:
    QFileDialog FileDialog(this, tr("Open File"), "C:\\", tr("Starcraft maps (*.scm *.scx *.chk);;All Files (*.*)"));
    FileDialog.exec();
    QString AString = FileDialog.directory().absolutePath();

    Works like a charm. Except for the fact that it's giving me a Qt open file dialog instead of a native windows open file dialog. I see an option for DontUseNativeDialog, but I don't see an option for DoUseNativeDialog.

  6. #5
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Wishing my windows build wasn't so windows like

    Use the static convenience function QFileDialog::getOpenFileName().
    J-P Nurmi

  7. #6
    Join Date
    Feb 2007
    Posts
    29
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Wishing my windows build wasn't so windows like

    And if I use that static convenience function, how the hell do I store the last used path in some QString?

  8. #7
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Wishing my windows build wasn't so windows like

    You can use QFileInfo to get the path of the selected file.
    Qt Code:
    1. QString path = <read from settings>
    2. QString file = QFileDialog::getOpenFileName(.., path, ..);
    3. if (!file.isNull())
    4. {
    5. path = QFileInfo(file).absolutePath();
    6. <store path setting>
    7. }
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  9. The following user says thank you to jpn for this useful post:

    scwizard (24th February 2007)

  10. #8
    Join Date
    Feb 2007
    Posts
    29
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Wishing my windows build wasn't so windows like

    Interesting, but is there a way to store the last visited directory even if the user presses the cancel button?

  11. #9
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Wishing my windows build wasn't so windows like

    Quote Originally Posted by scwizard View Post
    Interesting, but is there a way to store the last visited directory even if the user presses the cancel button?
    No, unfortunately there is no way for that when using the static method.
    J-P Nurmi

  12. #10
    Join Date
    Feb 2007
    Posts
    29
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Wishing my windows build wasn't so windows like

    Is there any way to to store the last visited directory even if the user presses the cancel button AND use the native dialog?

  13. #11
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Wishing my windows build wasn't so windows like

    Quote Originally Posted by scwizard View Post
    Is there any way to to store the last visited directory even if the user presses the cancel button AND use the native dialog?
    I'm afraid the static methods are the only ones for using native dialogs. So I'd say no..
    J-P Nurmi

Similar Threads

  1. converting unix exe to windows binary
    By deekayt in forum General Programming
    Replies: 2
    Last Post: 17th September 2006, 02:00
  2. Build windows app for Linux
    By cmaxb in forum Qt Programming
    Replies: 1
    Last Post: 19th June 2006, 20:40
  3. Qt and windows vista
    By munna in forum General Discussion
    Replies: 8
    Last Post: 11th January 2006, 23:33

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.