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. Wordundercursor in QPlainTextEdit
QtWS25 Last Chance

Wordundercursor in QPlainTextEdit

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

    Hi!

    When we double click on word in QPlainTextEdit then its gets selected. In QTCreator when we double click it selects whole variable not just word. I mean it includes underscore,dashes, multiple words in one double click.

    How can we implement such feature. What can we do so that just normal wordundercursor selects whole variable and not just single word.

    Thanks,
    Yash

    http://kineticwing.com : Web IDE, QSS Editor
    http://speedovation.com : Development Lab

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

      You have to use QTextEdit::ExtraSelection().
      The only example that I have at hand is written in Python, but it's quite simple:

      Method in Line 694:
      http://code.google.com/p/ninja-ide/source/browse/ninja_ide/gui/qt/main_panel/editor/editor.py?repo=kunai

      Diego Sarmentero
      Blog: http://diegosarmentero.com.ar
      Twitter: http://twitter.com/diegosarmentero

      1 Reply Last reply
      0
      • Y Offline
        Y Offline
        Yash
        wrote on last edited by
        #3

        I know this already. This is not what I mean. I want when you double click it should select variable not word. like
        @int m_word_word = 0@
        m_word_word is variable but when you double click on it, then one word only will be selected not whole variable. Try this in QPlainTextEdit you will understand what I mean.

        http://kineticwing.com : Web IDE, QSS Editor
        http://speedovation.com : Development Lab

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

          Yes, but you have to use QTextEdit::ExtraSelection() to tell QTextEdit which are the words that are going to be highlighted.

          Check out the link I mentioned... that is an IDE, where in that method the functionality that you mentioned is applied.

          Diego Sarmentero
          Blog: http://diegosarmentero.com.ar
          Twitter: http://twitter.com/diegosarmentero

          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