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 make painter->drawText selectable and NOT editable
Forum Updated to NodeBB v4.3 + New Features

How to make painter->drawText selectable and NOT editable

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

    Hi
    im using Listview item delegetor , and im drowing some texts in the items for example:
    @QString videoTitle = pItem->title();
    QRectF textBox = line.adjusted(PADDING+THUMB_WIDTH, PADDING, -2 * PADDING, -PADDING);
    textBox = painter->boundingRect( textBox, Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap, videoTitle);
    painter->drawText(textBox, Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap, videoTitle);
    painter->setFont(smallerFont);@

    what i need to add so it will be selectable and NOT editable so i could copy it with my mouse .

    1 Reply Last reply
    0
    • J Offline
      J Offline
      joonhwan
      wrote on last edited by
      #2

      How about creating editor typed QLineEdit with 'readOnly' property set If you wanna copy part of text ?
      Though the whole text will be copied after selecting cell if you press QKeySquence::Copy(Ctrl-C or CMD-C).

      joonhwan at gmail dot com

      1 Reply Last reply
      0
      • U Offline
        U Offline
        umen242
        wrote on last edited by
        #3

        Thanks for the replay , can you direct me to example code ?
        what do you mean "editor typed QLineEdit " ?

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

          Once you learn ow to use QAbstractItemDelegate class you will know about Its' memeber createEditor(),setEditorData(), and setModelData(). And then you will know how to create your own readonly QLineEdit Editor when select a item in your QAbstratItemView .

          joonhwan at gmail dot com

          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