Results 1 to 20 of 21

Thread: Why QFileDialog::getOpenFileName is not centered?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2009
    Posts
    132
    Thanks
    67
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Smile Why QFileDialog::getOpenFileName is not centered?

    Hi friends!

    Do you know why QFileDialog::getOpenFileName is shown not centered? When I call it, I pass my QMainWindow derived class pointer, but all my open dialogs are wrong, however, my own dialogs that derive from qdialog, are always centered.

    Any idea?

    Thanks in advance.

  2. #2
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Why QFileDialog::getOpenFileName is not centered?

    This is strange.
    Can you post the piece of your code where you call QFileDialog::getOpenFileName?
    A camel can go 14 days without drink,
    I can't!!!

  3. #3
    Join Date
    Apr 2009
    Posts
    132
    Thanks
    67
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Why QFileDialog::getOpenFileName is not centered?

    Sure:

    Qt Code:
    1. void CEditor::OpenLevel() {
    2. QString filename_and_folder=QFileDialog::getOpenFileName(this, "Load Level", QString(LEVELS_FOLDER), "Unprocessed Level (*.xml);;All files (*.*)");
    3. ...
    4. }
    To copy to clipboard, switch view to plain text mode 

    CEditor is derived from QMainWindow

    Any idea? Am I missing anythig?

    Thanks.

  4. #4
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Why QFileDialog::getOpenFileName is not centered?

    Sorry! The only idea was that the pointer passed as QFileDialog's parent was NULL.

    Maybe it's a bug.
    Last edited by mcosta; 28th July 2009 at 11:07. Reason: updated contents
    A camel can go 14 days without drink,
    I can't!!!

  5. #5
    Join Date
    Apr 2009
    Posts
    132
    Thanks
    67
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Why QFileDialog::getOpenFileName is not centered?

    Using the debugger, "this" has a correct value.

    And I read this on docs
    http://doc.trolltech.com/4.5/qfiledialog.html
    This function creates a modal file dialog with the given parent widget. If parent is not 0, the dialog will be shown centered over the parent widget.

    What's going on? Perhaps because I'm using a static call?

  6. #6
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    229
    Thanks
    2
    Thanked 29 Times in 28 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Why QFileDialog::getOpenFileName is not centered?

    The documentation on QFileDialog::getOpenFileName() says that the method, which is static, uses a native file dialog under Windows and not a QFileDialog.
    This native dialog doesn't seem to be able to be opened centred in a Qt application.

  7. #7
    Join Date
    Apr 2009
    Posts
    132
    Thanks
    67
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Why QFileDialog::getOpenFileName is not centered?

    Quote Originally Posted by Boron View Post
    The documentation on QFileDialog::getOpenFileName() says that the method, which is static, uses a native file dialog under Windows and not a QFileDialog.
    This native dialog doesn't seem to be able to be opened centred in a Qt application.
    Are you telling that it is impossible to show that dialog centered?
    It's difficult to believe. Can anyone tell me if he/she is having the same problem?

    Thanks.

  8. #8
    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: Why QFileDialog::getOpenFileName is not centered?

    Doesn't it depend on your system settings? Do dialogs in other applications (non-Qt) open themselves centered above their parents?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Apr 2009
    Posts
    132
    Thanks
    67
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Why QFileDialog::getOpenFileName is not centered?

    Quote Originally Posted by wysota View Post
    Doesn't it depend on your system settings?
    I don't know, I don't think so. Is Any Qt expert over there?


    Quote Originally Posted by wysota View Post
    Do dialogs in other applications (non-Qt) open themselves centered above their parents?
    Of course, I guess my windows is working nicely.

    Thanks

  10. #10
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    229
    Thanks
    2
    Thanked 29 Times in 28 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Why QFileDialog::getOpenFileName is not centered?

    I just saw that QFileDialog::getOpenFileName(...) uses almost the same file dialog as Windows Notpad.
    When using opening a file (menu File -> Open...) the dialog is not centered in Notepad. So the problem lies in Windows itself.

  11. #11
    Join Date
    Apr 2009
    Posts
    132
    Thanks
    67
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Why QFileDialog::getOpenFileName is not centered?

    Quote Originally Posted by Boron View Post
    I just saw that QFileDialog::getOpenFileName(...) uses almost the same file dialog as Windows Notpad.
    When using opening a file (menu File -> Open...) the dialog is not centered in Notepad. So the problem lies in Windows itself.
    Yes, you are right. But it would be nice to have a flag in order to select if you want to center that dialog, doesn't it? Maybe it is not possible because of Win32 API arquitecture, I don't know.

    Does Qt have any list where I can suggest new features?


    Thanks.

Similar Threads

  1. centered text label
    By djconnel in forum Qwt
    Replies: 5
    Last Post: 28th April 2009, 17:22
  2. [Qt4]: Adding centered items in QListWidget
    By Jojo in forum Qt Programming
    Replies: 4
    Last Post: 16th March 2006, 20:04

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.