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. Copy QTableWidget cell content to clipboard

Copy QTableWidget cell content to clipboard

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 4.9k 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.
  • I Offline
    I Offline
    Imhotep
    wrote on last edited by
    #1

    I built up a context menu that opens with right-click on the cell in a QTableWidget. Could you help me to create a command to copy the contents of that cell to the clipboard? The examples I have found on the web are really bad.

    Thanks in advance

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andreyc
      wrote on last edited by
      #2

      I don't have any examples for "QClipboard":http://qt-project.org/doc/qt-5/qclipboard.html under my hands so this is my idea

      • get the system clipboard
        @
        clipboard = QApplication::clipboard();
        @

      • connect copy menu item to some slot

      • in the slot put a content of QTableWidget cell into clipboard
        @
        clipboard->setText(lineEdit->text(), QClipboard::Clipboard);
        clipboard->setText(lineEdit->text(), QClipboard::Selection);
        @

      See "here":http://qt-project.org/doc/qt-5/qtwidgets-widgets-charactermap-example.html#mainwindow-class-implementation for additional details
      or if you have installed Qt from qt-project websiate then
      @
      Qt/Examples/Qt-5.3/widgets/widgets/charactermap/
      @

      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