Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Problem with QFileDialog
Forum Updated to NodeBB v4.3 + New Features

Problem with QFileDialog

Scheduled Pinned Locked Moved General and Desktop
7 Posts 4 Posters 4.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    QBall
    wrote on last edited by
    #1

    First and for most I am new to Qt so my apologies if I use this forum incorrectly or place things in the wrong place (If I do please tell me and I will do my best to correct it).

    I seam to be having an issue with QFileDialog

    I have a method inside a class (which inherits QMainWindow) which gets the name of a file to save to. My code is shown below

    @fileSave = new QFileDialog(this, Qt::Sheet);
    fileSave->setNameFilter("PDF-Files (*.pdf)");
    fileSave->setAcceptMode(QFileDialog::AcceptSave);
    connect(fileSave, SIGNAL(finished(int)), this, SLOT(saveAccepted(int)));
    fileSave->show();@

    This works until the user clicks save or cancel in which I get a EXC_BAD_ACCESS Signal.

    I am using the stock standard 4.6 install on Mac Os X (I am running Snow Leopard with all the updates).

    The problem does not occur if I remove the line: fileSave->setAcceptMode(QFileDialog::AcceptSave); but then it displays an open dialog.

    My apologies if this is something small or I am doing something very stupid.

    Thanks

    QBALL

    1 Reply Last reply
    0
    • F Offline
      F Offline
      Felix
      wrote on last edited by
      #2

      have you tried the static method QFileDialog::getSaveFileName()? I use this at most when i ned to get a file or directory. It also has the native OS - Style

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        QBall
        wrote on last edited by
        #3

        Thanks for your quick reply

        Yes I have tried that and it did have the native style (which is preferable) but it did not use the sheet look (even when I used Qt:Sheet). I need the open dialog to be associated with the window on Mac.

        I will continue to look at how to get the static methods to use the sheets though.

        Cheers

        QBall

        1 Reply Last reply
        0
        • Q Offline
          Q Offline
          QTanisa
          wrote on last edited by
          #4

          Select file/directory path using QFileDialog in Qt

          I want to show a dialog to user to select a file/directory in qt. I tried using QFileDialog to get it, but either i can set file mode or directory mode, could not able to set both. if I set QFileDialog::Directory as file mode it shows directories as well as files, but could not able to select any file. i need solution for selecting file as well as directory in the QFileDialog or help me with alternate way....

          1 Reply Last reply
          0
          • Q Offline
            Q Offline
            QTanisa
            wrote on last edited by
            #5

            Select file/directory path using QFileDialog in Qt

            I want to show a dialog to user to select a file/directory in qt. I tried using QFileDialog to get it, but either i can set file mode or directory mode, could not able to set both. if I set QFileDialog::Directory as file mode it shows directories as well as files, but could not able to select any file. i need solution for selecting file as well as directory in the QFileDialog or help me with alternate way....

            1 Reply Last reply
            0
            • K Offline
              K Offline
              kumararajas
              wrote on last edited by
              #6

              [quote author="QTanisa" date="1418189700"]Select file/directory path using QFileDialog in Qt

              I want to show a dialog to user to select a file/directory in qt. I tried using QFileDialog to get it, but either i can set file mode or directory mode, could not able to set both. if I set QFileDialog::Directory as file mode it shows directories as well as files, but could not able to select any file. i need solution for selecting file as well as directory in the QFileDialog or help me with alternate way....[/quote]

              Hi,

              You might think for setting the file mode. There are various modes that you can set in:

              enum QFileDialog::FileMode
              This enum is used to indicate what the user may select in the file dialog; i.e. what the dialog will return if the user clicks OK.
              Constant Value Description
              QFileDialog::AnyFile 0 The name of a file, whether it exists or not.
              QFileDialog::ExistingFile 1 The name of a single existing file.
              QFileDialog::Directory 2 The name of a directory. Both files and directories are displayed.
              QFileDialog::ExistingFiles 3 The names of zero or more existing files.

              "Qt documentation link":http://qt-project.org/doc/qt-4.8/qfiledialog.html#FileMode-enum

              Example:
              @
              QFileDialog dialog;
              dialog.setFileMode(QFileDialog::AnyFile);
              @

              --Kumar

              1 Reply Last reply
              0
              • K Offline
                K Offline
                kumararajas
                wrote on last edited by
                #7

                [quote author="QTanisa" date="1418189700"]Select file/directory path using QFileDialog in Qt

                I want to show a dialog to user to select a file/directory in qt. I tried using QFileDialog to get it, but either i can set file mode or directory mode, could not able to set both. if I set QFileDialog::Directory as file mode it shows directories as well as files, but could not able to select any file. i need solution for selecting file as well as directory in the QFileDialog or help me with alternate way....[/quote]

                Hi,

                You might think for setting the file mode. There are various modes that you can set in:

                enum QFileDialog::FileMode
                This enum is used to indicate what the user may select in the file dialog; i.e. what the dialog will return if the user clicks OK.
                Constant Value Description
                QFileDialog::AnyFile 0 The name of a file, whether it exists or not.
                QFileDialog::ExistingFile 1 The name of a single existing file.
                QFileDialog::Directory 2 The name of a directory. Both files and directories are displayed.
                QFileDialog::ExistingFiles 3 The names of zero or more existing files.

                "Qt documentation link":http://qt-project.org/doc/qt-4.8/qfiledialog.html#FileMode-enum

                Example:
                @
                QFileDialog dialog;
                dialog.setFileMode(QFileDialog::AnyFile);
                @

                --Kumar

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved