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

Copy to clipboard does not work any more

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Not Evaluated
    • None
    • 4.5.3
    • None
    • None
    • Windows XP, Visual Studio 2005

    Description

      Copying simple plain text data does not work any more! It used to work with version 4.4.3, then the exactly same code did not work any more with versions 4.5.1 and 4.5.3.

      Code snippet:

      ====================
      std::ostringstream ostr;

      // data is streamed into ostr with << operator
      // ....

      // Plain Windows API version
      // Note: Since version 4.5.1, QClipboard does not seem to work any more (!??)

      /*
      QByteArray plainText(ostr.str().c_str());
      if(OpenClipboard(0))

      { EmptyClipboard(); HGLOBAL hPlain = GlobalAlloc(GMEM_MOVEABLE |GMEM_DDESHARE, plainText.size() + 4); char* plainPtr = (char*)GlobalLock(hPlain); strcpy(plainPtr, plainText.constData()); GlobalUnlock(hPlain); ::SetClipboardData(CF_TEXT, hPlain); CloseClipboard(); GlobalFree(hPlain); }

      */

      // Qt clipboard functions version that does not work any more since version 4.5.1

      QClipboard* clipboard = QApplication::clipboard();
      clipboard->setText(ostr.str().c_str());
      ====================

      More details:

      Using a clipboard list tool and running the code with Qt version 4.4.3, I saw the following data types on the clipboard after a "copy":

      DataObject
      Unicode Text
      Plain Text
      Ole Private Data
      Locale Identifier
      OEM Text

      With version 4.5.3, I simply get an empty clipboard!

      Finally, the version that directly calls the Windows API functions as shown above in the code snippet, I am getting:

      Plain Text
      Locale Identifier
      OEM Text
      Unicode Text

      which is more than enough for my program!

      For my part, I can live with the direct Windows API calls, but it is not pretty anyway - and others may have more trouble!

      Attachments

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

        Activity

          People

            sorvig Morten Sørvig
            cbockem Cornelis Bockemühl
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes