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: how to determine if data was copied (Ctrl+C) or cut to the clipboard in another application?
QtWS25 Last Chance

QClipBoard: how to determine if data was copied (Ctrl+C) or cut to the clipboard in another application?

Scheduled Pinned Locked Moved General and Desktop
9 Posts 2 Posters 2.3k 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.
  • V Offline
    V Offline
    Violet Giraffe
    wrote on last edited by
    #1

    My application is clipboard-enabled and is able to accept mime data (not just plain text). Is it possible to know whether the data was put to clipboard by another application with Ctrl+X or Ctrl+C?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      Dave007
      wrote on last edited by
      #2

      On wich platform should ur application run?

      1 Reply Last reply
      0
      • V Offline
        V Offline
        Violet Giraffe
        wrote on last edited by
        #3

        Windows / OSX / Linux, but Windows is primary.

        1 Reply Last reply
        0
        • D Offline
          D Offline
          Dave007
          wrote on last edited by
          #4

          I know under Windows u can try to poll the State of the two keys with the GetAsyncKeyState Function:
          http://msdn.microsoft.com/en-us/library/windows/desktop/ms646293(v=vs.85).aspx

          But I don't know how to solve that on the other platforms.

          1 Reply Last reply
          0
          • V Offline
            V Offline
            Violet Giraffe
            wrote on last edited by
            #5

            That's hardly a solution because pressing Ctrl+C or Ctrl+X in another app doesn't trigger any event in my program. Paste is the event I need to handle properly.

            1 Reply Last reply
            0
            • D Offline
              D Offline
              Dave007
              wrote on last edited by
              #6

              I think a better way of solving the Problem is to react on the dataChange Signal wich is emitted when the data in the clipboard were changed:

              http://qt-project.org/doc/qt-4.8/qclipboard.html#dataChanged

              1 Reply Last reply
              0
              • D Offline
                D Offline
                Dave007
                wrote on last edited by
                #7

                So only that I know what u want to do:

                Should your application react when something is put into the clipboard?
                Or when something is pasted into another application with Ctrl+V?

                1 Reply Last reply
                0
                • V Offline
                  V Offline
                  Violet Giraffe
                  wrote on last edited by
                  #8

                  The data (file URLs) is copied in another application and pasted into mine. At which point I need to know whether I must delete the original files or not.

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    Dave007
                    wrote on last edited by
                    #9

                    If u paste it into a QTextEdit or QLineEdit u can react on the textChanged Signal.
                    I think getting the Ctrl+V press Event is harder to react on different platforms.

                    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