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 and QFileDialog::DontUseNativeDialog

Problem with QFileDialog and QFileDialog::DontUseNativeDialog

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 480 Views
  • 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.
  • J Offline
    J Offline
    JonexElectronic
    wrote on last edited by
    #1

    Error with the preview of image files, they are not shown. If I use it natively, the preview is shown. Any solution?
    Here is my code

    QFileDialog dialog(padre, "Load Icon", nombreFile, "Image files (*.png *.jpg *.bmp *.gif)");
    dialog.setFileMode(QFileDialog::ExistingFile);
    dialog.setViewMode(QFileDialog::List);
    dialog.setOptions(QFileDialog::DontUseNativeDialog);
    dialog.setGeometry(padre->geometry());
    QString nombreFile1;
    if (dialog.exec()==QDialog::Accepted)
    	nombreFile1 = dialog.selectedFiles().first();
    rect=dialog.geometry();
    if (nombreFile1.isEmpty())
    	nombreFile=dialog.directory().absolutePath();
    else
    {
    	nombreFile=nombreFile1;
    	QPixmap pixmap(nombreFile);
    	if (pixmap.isNull())
    		error(MainWindow::tr("File fault"));
    	else
    	{
    		pixmap=pixmap.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
    		pixmap.save(sss);
    		rt=true;
    	}
    }
    

    And this is how it looks with DontUseNativeDialog

    573cae99-261d-4a48-b48c-fa6ba2d79ed1-image.png

    And now with native
    8d1a1715-2ec2-4ab8-80b5-37a653cfb53c-image.png

    Christian EhrlicherC 1 Reply Last reply
    0
    • J JonexElectronic

      Error with the preview of image files, they are not shown. If I use it natively, the preview is shown. Any solution?
      Here is my code

      QFileDialog dialog(padre, "Load Icon", nombreFile, "Image files (*.png *.jpg *.bmp *.gif)");
      dialog.setFileMode(QFileDialog::ExistingFile);
      dialog.setViewMode(QFileDialog::List);
      dialog.setOptions(QFileDialog::DontUseNativeDialog);
      dialog.setGeometry(padre->geometry());
      QString nombreFile1;
      if (dialog.exec()==QDialog::Accepted)
      	nombreFile1 = dialog.selectedFiles().first();
      rect=dialog.geometry();
      if (nombreFile1.isEmpty())
      	nombreFile=dialog.directory().absolutePath();
      else
      {
      	nombreFile=nombreFile1;
      	QPixmap pixmap(nombreFile);
      	if (pixmap.isNull())
      		error(MainWindow::tr("File fault"));
      	else
      	{
      		pixmap=pixmap.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation);
      		pixmap.save(sss);
      		rt=true;
      	}
      }
      

      And this is how it looks with DontUseNativeDialog

      573cae99-261d-4a48-b48c-fa6ba2d79ed1-image.png

      And now with native
      8d1a1715-2ec2-4ab8-80b5-37a653cfb53c-image.png

      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @JonexElectronic said in Problem with QFileDialog and QFileDialog::DontUseNativeDialog:

      Error with the preview of image files, they are not shown. If I use it natively, the preview is shown. Any solution?

      dialog.setViewMode(QFileDialog::List);

      What do you expect when you set QFileDialog::List? The Qt filedialog does not support previews.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      J 1 Reply Last reply
      0
      • Christian EhrlicherC Christian Ehrlicher

        @JonexElectronic said in Problem with QFileDialog and QFileDialog::DontUseNativeDialog:

        Error with the preview of image files, they are not shown. If I use it natively, the preview is shown. Any solution?

        dialog.setViewMode(QFileDialog::List);

        What do you expect when you set QFileDialog::List? The Qt filedialog does not support previews.

        J Offline
        J Offline
        JonexElectronic
        wrote on last edited by
        #3

        @Christian-Ehrlicher So, what should I use? Is there something I can use then that allows me to preview?

        JonBJ 1 Reply Last reply
        0
        • J JonexElectronic

          @Christian-Ehrlicher So, what should I use? Is there something I can use then that allows me to preview?

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @JonexElectronic
          If (a) the non-native (i.e. Qt) dialog does not offer preview and (b) the native one either also does not or for some reason you cannot use it, then you would have no choice but to write your own which did offer this "preview" facility.

          1 Reply Last reply
          1

          • Login

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