Results 1 to 2 of 2

Thread: Multiple Files

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2018
    Posts
    1
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Multiple Files

    How we can open multiple files(images) in Qt. I have written a code but this only opens a single image. Here is the Qt code.

    Qt Code:
    1. QFileDialog dialog(this);
    2. dialog.setNameFilter(tr("Images (*.png *.xpm *.jpg)"));
    3. dialog.setViewMode(QFileDialog::Detail);
    4. dialog.setFileMode(QFileDialog::ExistingFiles);
    5. QString fileName = QFileDialog::getOpenFileName(this,
    6. tr("Open Images"), "C:/Users/hamza/Desktop/New folder", tr("Image Files (*.png *.jpg *.bmp);;All Files (*.*)"));
    7. if (dialog.exec())
    8. fileName=dialog.selectedFiles();
    9. if (!fileName.isEmpty())
    10. {
    11. QImage image(fileName);
    12. image = image.scaledToWidth(ui->label_pic->width(),Qt::SmoothTransformation);
    13. ui->label_pic->setPixmap(QPixmap::fromImage(image));
    14. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by high_flyer; 9th January 2018 at 10:03. Reason: missing [code] tags

Similar Threads

  1. Multiple UI files
    By Diblye in forum Newbie
    Replies: 5
    Last Post: 29th June 2012, 00:24
  2. QFtp get multiple files?
    By hexie in forum Qt Programming
    Replies: 0
    Last Post: 12th March 2012, 08:24
  3. Qt Multiple Ui files.....
    By Rajeshsan in forum Qt Programming
    Replies: 4
    Last Post: 19th January 2010, 04:14
  4. example project with multiple .ui files
    By navid in forum Newbie
    Replies: 1
    Last Post: 31st October 2009, 18:25
  5. Error: Using Multiple files
    By 3nc31 in forum Qt Programming
    Replies: 1
    Last Post: 22nd November 2007, 09:23

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.