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. Get image from QTableWidgetItem

Get image from QTableWidgetItem

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

    I set table widget item
    QTableWidgetItem *thumbnail = new QTableWidgetItem;
    //
    thumbnail->setData(Qt::DecorationRole, ( QPixmap( url.path() ) ).scaled(144, 168));
    ui->tableWidget->setItem(row, 1, thumbnail);

    How I can get image from this cell?

    1 Reply Last reply
    0
    • hskoglundH Offline
      hskoglundH Offline
      hskoglund
      wrote on last edited by hskoglund
      #2

      Hi, you mean the image is not visible? Maybe try instead:

      QTableWidgetItem *thumbnail = new QTableWidgetItem( QIcon( QPixmap( url.path() ) .scaled(144, 168)),"");
      //
      ui->tableWidget->setItem(row, 1, thumbnail);
      1 Reply Last reply
      1
      • S Offline
        S Offline
        sashapont
        wrote on last edited by
        #3

        No it is visible and i want to get it and save to file

        1 Reply Last reply
        0
        • hskoglundH Offline
          hskoglundH Offline
          hskoglund
          wrote on last edited by
          #4

          Ok I see, guessing but it should be something like:
          QPixmap m = ui->tablewidget->item(row,1)->data(Qt::DecorationRole);

          1 Reply Last reply
          1
          • S Offline
            S Offline
            sashapont
            wrote on last edited by
            #5

            @hskoglund said:

            QPixmap m = ui->tablewidget->item(row,1)->data(Qt::DecorationRole);

            no viable conversion from 'QVariant' to 'QPixmap'

            1 Reply Last reply
            0
            • hskoglundH Offline
              hskoglundH Offline
              hskoglund
              wrote on last edited by
              #6

              Sorry :-) try this:

              QPixmap m = ui->tablewidget->item(row,1)->data(Qt::DecorationRole).value<QPixmap>();
              1 Reply Last reply
              1
              • S Offline
                S Offline
                sashapont
                wrote on last edited by
                #7

                Thank you very much!!!! It is work!

                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