Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Image saved to picture but return false
Qt 6.11 is out! See what's new in the release blog

Image saved to picture but return false

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 552 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.
  • R Offline
    R Offline
    RyuShai
    wrote on last edited by
    #1

    i got problem so crazy
    first i take picture by camera in qml them store it to image. Then i used graptoimage to save this picture to disk but file it saved in Pictures folder (default folder of ubuntu ) in different name, look like "IMG_00000001.jpg"
    here 2 part of code

    qml

    console.log("grab to image")
                imagePreview.grabToImage(function(result){
                    control.cvtImg2Base64(result);
                })
    

    c++

    QString MainControl::cvtImg2Base64(QVariant var)
    {
        qDebug()<<Q_FUNC_INFO;
        QImage img = qvariant_cast<QImage>(var);
        qDebug()<<img.save("/home/ryu/Pictures/ryu.jpg"); //return false
        QPixmap pix = QPixmap::fromImage(img);
        qDebug()<<pix.save("/home/ryu/Pictures/shai.jpg"); //return false
    

    anyone can explain for me WHY ?

    1 Reply Last reply
    0
    • N Offline
      N Offline
      Nifiro
      wrote on last edited by
      #2

      https://doc.qt.io/qt-5/qml-qtquick-itemgrabresult.html#image-prop

      console.log("grab to image")
                  imagePreview.grabToImage(function(result){
                      control.cvtImg2Base64(result.image);
                  })
      
      QString MainControl::cvtImg2Base64(QImage img)
      {
          qDebug()<<Q_FUNC_INFO;
          qDebug()<<img.save("/home/ryu/Pictures/ryu.jpg");
          QPixmap pix = QPixmap::fromImage(img);
          qDebug()<<pix.save("/home/ryu/Pictures/shai.jpg");
      }
      
      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