Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-27249

Inserting QImage in QTextEdit from QMimeData inserts it in wrong colors (only green&white) (perhaps qvariant_cast bug)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P2: Important
    • None
    • 5.0.0 Beta 1
    • None
    • MinGW 4.7.0, Windows 7, Qt 5.0.0 beta

    Description

      Reimplemented insertFromMimeData function of QTextEdit to add possibility to insert images from clipboard(for example, copied from browser). Everything works fine on Qt 4.8.2 and works wrong on Qt 5.0.0 beta.
      class CustomTextEdit : public QTextEdit

      {...}

      void CustomTextEdit::insertFromMimeData(const QMimeData *source)
      {
      QTextCursor cursor = this->textCursor();
      if (source->hasImage())

      { QImage image = qvariant_cast<QImage>(source->imageData()); //image.save("C:/1.jpg"); // here we can see wrong image saved in file // QImage image = source->imageData().value<QImage>(); // gives the same result image.convertToFormat(QImage::Format_ARGB32_Premultiplied); cursor.insertImage(image, "name"); }

      else

      { QTextEdit::insertFromMimeData(source); }

      }

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              kleint Friedemann Kleint
              selma Selma
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes