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. QClipboard duplicate image
Forum Updated to NodeBB v4.3 + New Features

QClipboard duplicate image

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 696 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.
  • PerdrixP Offline
    PerdrixP Offline
    Perdrix
    wrote on last edited by Perdrix
    #1

    I have code in my application to copy the content of a widget called picture to the clipboard.

    			QClipboard* clipboard = QGuiApplication::clipboard();
    
    			QPixmap pix{ picture->grab() };
    			clipboard->setPixmap(pix);
    

    which works fine. When that code is called the content of the widget is added to the system clipboard.

    The oddness happens when the the application is closed: A duplicate of the last copy is added to the system clipboard.

    FWIW this is using Qt 6.8.0 MSVC2022 on Windows 11

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by ChrisW67
      #2

      Does this still happen if you call QClipboard::clear() before exiting?

      Edit. Perhaps only clear it if is yours.

      if (clipboard->ownsClipboard())
        clipboard->clear();
      
      1 Reply Last reply
      0
      • PerdrixP Offline
        PerdrixP Offline
        Perdrix
        wrote on last edited by
        #3

        Won't that delete what I already placed on the clipboard? I don't want to do that ...

        C 1 Reply Last reply
        0
        • Christian EhrlicherC Online
          Christian EhrlicherC Online
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          How do you know that there is a second image added? Does it also happen with a small reproducer? A simple main() adding an image to the clipboard?

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          0
          • PerdrixP Perdrix

            Won't that delete what I already placed on the clipboard? I don't want to do that ...

            C Offline
            C Offline
            ChrisW67
            wrote on last edited by
            #5

            @Perdrix Yes, but as a debugging step it will also tell you if the duplication (if there is one) happens during exit.

            1 Reply Last reply
            0
            • PerdrixP Offline
              PerdrixP Offline
              Perdrix
              wrote on last edited by
              #6

              I know because I use a Gadget that keeps track of all items added to the clipboard. When the code above is executed the image is shown in the gadget, and then when I exit the application it is added again.

              1 Reply Last reply
              0
              • PerdrixP Offline
                PerdrixP Offline
                Perdrix
                wrote on last edited by
                #7

                Still a problem

                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