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. How to allow user to copy text from read-only QTextEdit?
Forum Updated to NodeBB v4.3 + New Features

How to allow user to copy text from read-only QTextEdit?

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 1.3k 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.
  • J Offline
    J Offline
    jellyv
    wrote on last edited by
    #1

    I have a read-only QTextEdit on my form, which obviously isn't supposed to be edited by the user. However, I want the user to be able to copy its contents, just like a non-readonly QTextEdit (by selecting the text with mouse and clicking ctrl+c , or right click-> copy). Any ideas how I could do that?

    I'm using QT qreator 3.6.1, based on QT 5.6.0. Compiler: MSVC 2013, 32 bit.

    JonBJ 1 Reply Last reply
    1
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #3

      Hi
      ReadOnly allows copy still
      alt text

      1 Reply Last reply
      4
      • J jellyv

        I have a read-only QTextEdit on my form, which obviously isn't supposed to be edited by the user. However, I want the user to be able to copy its contents, just like a non-readonly QTextEdit (by selecting the text with mouse and clicking ctrl+c , or right click-> copy). Any ideas how I could do that?

        I'm using QT qreator 3.6.1, based on QT 5.6.0. Compiler: MSVC 2013, 32 bit.

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by JonB
        #2

        @jellyv
        I have not checked, but I would have expected a read-only still to be copyable, you are sure you have not disabled it rather than making it read-only?

        1 Reply Last reply
        5
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #3

          Hi
          ReadOnly allows copy still
          alt text

          1 Reply Last reply
          4
          • J Offline
            J Offline
            jellyv
            wrote on last edited by
            #4

            You're right guys.. the problem isn't in read-only property.. I had set the focusPolicy to "NoFocus", which didn't let me copy QTextEdit's value.. I simply changed it to "ClickFocus", and now works as expected.

            1 Reply Last reply
            4

            • Login

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