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. QFileDialog::getSaveFileName() return file name without extension [Linux, Ubuntu, x64, Qt 5.2.1]
Forum Updated to NodeBB v4.3 + New Features

QFileDialog::getSaveFileName() return file name without extension [Linux, Ubuntu, x64, Qt 5.2.1]

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 3.4k 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.
  • N Offline
    N Offline
    nen777w
    wrote on last edited by
    #1

    Code example:
    @
    QString supported_formats = "Joint Photographic Experts Group (.jpg);;Joint Photographic Experts Group (.jpeg);;Portable Network Graphics (.png);;Windows Bitmap (.bmp);;Portable Bitmap (.pbm);;Portable Graymap (.pgm);;Portable Pixmap (.ppm);;X11 Bitmap (.xbm);;X11 Pixmap (.xpm);;Tagged Image File Format (.tif);;Tagged Image File Format (.tiff);;Wireless Application Protocol Bitmap Format (.wbmp)";

    QString fileName = QFileDialog::getSaveFileName(this, tr("Export Image"), "", supported_formats, 0, 0);
    @

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You should also add which version of Qt you are using

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • N Offline
        N Offline
        nen777w
        wrote on last edited by
        #3

        Change subject: [Linux, Ubuntu, x64, Qt 5.2.1]

        1 Reply Last reply
        0
        • Z Offline
          Z Offline
          zeljko
          wrote on last edited by
          #4

          hm, when Qt uses any gtk theme then it loads (uses) native gtk2 file dialog (GtkFileChooser), so I'm just wondering what Qt have with extension in this case.When you save your filename you should add extension to that file manually, especially in case when you have dozen of extensions in one filter - how Qt can decide which one it should have (if you didn't type any into FileName QLineEdit).
          Problem is that extension change in native dialog does not trigger any signal, so you don't know what extension should be before closing GtkFileChooser. Use non-native (non static) stuff if you want more control over Open/Save dialogs.

          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