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. How to get QPixmap from QItemSelection?

How to get QPixmap from QItemSelection?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 934 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.
  • S Offline
    S Offline
    swseo
    wrote on last edited by
    #1

    Hello.

    How can I get QPixmap from QItemSelection?

    I am trying to make an image viewer. Currently, I have successfully loaded images to QstandarditemModel as below.
    Now, I would like to show an enlarged image which is selected by mouse clicked. To do so, I think, first, I should get QPixmap from QItemSelection in order to show into QLabel Box.

    Please help.

    Thank you.

    @
    this->model = new QStandardItemModel();
    ui->listView->setModel(this->model);
    ui->listView->setGridSize(QSize(320, 240));
    ui->listView->setIconSize(QSize(280, 200));
    ui->listView->setViewMode(QListView::IconMode);
    QObject::connect(ui->listView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(imageSelectionChanged(QItemSelection)));

    //---------Load Button Event ------------
    QFileDialog::Options options;
    options |= QFileDialog::DontUseNativeDialog;

    QString selectedFilter;
    QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("QFileDialog::getOpenFileNames()"), "./../data", tr("All Files ();;Image Files (.bmp)"), &selectedFilter, options);
    for (int i = 0; i < fileNames.count(); i++) {
    QStandardItem *item = new QStandardItem(QIcon(fileNames[i]), fileNames[i]);
    this->model->appendRow(item);
    }
    @

    [edit: added missing coding tags @ SGaist]

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

      Hi and welcome to devnet,

      You should rather load it from the same file used to create the icon. Your QIcon will have a reduced version of the image while you rather want to have the original.

      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

      • Login

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