Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Brainstorm
  4. QPlainTextEdit : Make block readonly?
QtWS25 Last Chance

QPlainTextEdit : Make block readonly?

Scheduled Pinned Locked Moved Brainstorm
12 Posts 3 Posters 8.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.
  • A Offline
    A Offline
    aviral
    wrote on 2 Aug 2010, 05:31 last edited by
    #2

    Can u elaborate a bit more on the requirement ....this could help to design a custom widget where in u can have QTextCursorblock (s) or some modification like MyQPlainTextEdit has a MyQTextContent and both of this can have their own implementations.

    Need more details on requirement to put some concrete code fwd.

    1 Reply Last reply
    0
    • Y Offline
      Y Offline
      Yash
      wrote on 2 Aug 2010, 12:04 last edited by
      #3

      Ok

      Consider a case when you editing some text in a editor. Now you open this(block of text) in new editor (with some more options) now I want unless I close that second editor first editor should make that selected text as readonly (not in selection mode anymore) that means I can edit any other text apart from that block (piece of text) in first editor.

      Is it clear?

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

      1 Reply Last reply
      0
      • ? This user is from outside of this forum
        ? This user is from outside of this forum
        Guest
        wrote on 2 Aug 2010, 12:52 last edited by
        #4

        It is possible to do what you want. You should extend the QPlainTextEdit, and build in this sort of behavior. You can get the block(s) you are interested in and then customize how you want it to behave. These specific blocks can give you their bounds and then you can control events in these bounds. I think that should work. Not sure if there is an easier way.

        1 Reply Last reply
        0
        • Y Offline
          Y Offline
          Yash
          wrote on 2 Aug 2010, 16:13 last edited by
          #5

          yea looking for easy way because I feel short code always smart to use and write but difficult to think.

          Thanks you for your suggestion.

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

          1 Reply Last reply
          0
          • ? This user is from outside of this forum
            ? This user is from outside of this forum
            Guest
            wrote on 3 Aug 2010, 11:50 last edited by
            #6

            relooked at this... did u come up with any alternate approach? u have me curious now :)

            1 Reply Last reply
            0
            • T Offline
              T Offline
              tzander
              wrote on 8 Aug 2010, 22:22 last edited by
              #7

              You could connect to the QPlainTextEdit::cursorPositionChanged () signal on both editors and when the user changes the position of the second editor to be inside the block the first is editing you can move the cursor outside of that block quickly

              That might do the trick without inheriting.

              1 Reply Last reply
              0
              • ? This user is from outside of this forum
                ? This user is from outside of this forum
                Guest
                wrote on 9 Aug 2010, 02:54 last edited by
                #8

                @thomas, but that would show the cursor jump from the position set to outside of the block. might not be smooth, especially under load

                1 Reply Last reply
                0
                • T Offline
                  T Offline
                  tzander
                  wrote on 9 Aug 2010, 06:26 last edited by
                  #9

                  @chetankjain the 'under load' problem should not exist as signals in Qt are executed immediately without delay. So the moment the user hits the key and its handled by Qt, the user code is executed.

                  1 Reply Last reply
                  0
                  • ? This user is from outside of this forum
                    ? This user is from outside of this forum
                    Guest
                    wrote on 9 Aug 2010, 07:09 last edited by
                    #10

                    @thomas there is a finite gap between the moment user hits the key and the execution of user code, but under heavy system load this gap could magnify

                    1 Reply Last reply
                    0
                    • Y Offline
                      Y Offline
                      Yash
                      wrote on 9 Aug 2010, 07:28 last edited by
                      #11

                      This may help QPlainTextEdit::cursorPositionChanged () but again watching this an overhead.

                      I want only a specific block and whole editor. I agree with chetankjain about this overhead load.

                      Thank you for suggesstions. :)

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

                      1 Reply Last reply
                      0
                      • Y Offline
                        Y Offline
                        Yash
                        wrote on 16 Aug 2010, 07:52 last edited by
                        #12

                        bq. Yes you can. E.g. for all non editable blocks use QTextBlock::setUserState() and give them 666. Then reimp keypress event or install an event filter and check if the cursor is in a block where the user value is 666. If so, don't propagate the event. That's all.

                        I'm looking for something like this. Cheers :)

                        "Original":http://www.qtcentre.org/threads/32609-a-Readonly-Highlighted-TextBlock-in-QTextEdit?p=151542#post151542

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

                        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