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. is it possible to to Ctrl C on QLabel
Forum Updated to NodeBB v4.3 + New Features

is it possible to to Ctrl C on QLabel

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 1.4k Views 3 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.
  • Q Offline
    Q Offline
    Qt Enthusiast
    wrote on last edited by
    #1

    is it possible to to Ctrl C and Control V on QLabel

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mostefa
      wrote on last edited by mostefa
      #2

      Hi

      Yes it is possible by setting the textInteractionFlags of your QLabel:

      http://doc.qt.io/qt-5/qlabel.html#textInteractionFlags-prop

      You to choose :

      Qt::TextSelectableByMouse which means :

      Text can be selected with the mouse and copied to the clipboard using a context menu or standard keyboard shortcuts.

      this is the list of possible interaction flags:

      http://doc.qt.io/qt-5/qt.html#TextInteractionFlag-enum

      Your code have to look to something like this:

      label->setTextInteractionFlags(Qt::TextSelectableByMouse);

      I hope this can help you !

      1 Reply Last reply
      4
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        To add to @mostefa, you can't past on a QLabel unless you implement that yourself.

        However if you want both options, why not use a QLineEdit ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        3
        • Q Offline
          Q Offline
          Qt Enthusiast
          wrote on last edited by
          #4

          I dont want to paste on QLable but want to copy this QLable and paste it to other places

          M 1 Reply Last reply
          0
          • Q Qt Enthusiast

            I dont want to paste on QLable but want to copy this QLable and paste it to other places

            M Offline
            M Offline
            mostefa
            wrote on last edited by
            #5

            @Qt-Enthusiast said in is it possible to to Ctrl C on QLabel:

            I dont want to paste on QLable but want to copy this QLable and paste it to other places

            Then , as i suggested , you can use

            label->setTextInteractionFlags(Qt::TextSelectableByMouse);

            1 Reply Last reply
            1

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved