Results 1 to 4 of 4

Thread: a Readonly Highlighted TextBlock in QTextEdit?

  1. #1
    Join Date
    Jul 2010
    Posts
    20
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Question a Readonly Highlighted TextBlock in QTextEdit?

    Hi all, i decided to make a texteditor which can edit special format textfile(with tags like (Color:red)Text(Type:4) in it),

    It's easy to Highlight Text in a Tag pair with QSyntaxHighlighter, but ,I WANT TO HIDE THE TAGS ,AND MAKE the text in a Tag pair Non-editable

    So ,how can i make a Text block Non-editable , while other blocks editable?


    Thx. & Sry for my english

  2. #2
    Join Date
    Apr 2010
    Location
    Rostov-na-Donu, Russia
    Posts
    153
    Thanks
    2
    Thanked 26 Times in 23 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: a Readonly Highlighted TextBlock in QTextEdit?

    1. if these tags are not editable, then how can user to add them ?
    2. you can parse input file, remove these tags, and make a formatted textblocks instead of them. when you will save a file you should surround formatted textblocks with these tags

  3. #3
    Join Date
    Jul 2010
    Posts
    20
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: a Readonly Highlighted TextBlock in QTextEdit?

    Quote Originally Posted by borisbn View Post
    1. if these tags are not editable, then how can user to add them ?
    2. you can parse input file, remove these tags, and make a formatted textblocks instead of them. when you will save a file you should surround formatted textblocks with these tags
    Thx for your Reply:

    1.The reason making the Tags and Text in them non-editable is to prevent users editing them by mistake, The tool is wrote for translation purpose, and the source texts are generated by a program;
    2.The biggest problem is making a selected textblock non-editable, i can leave all tags visiable;

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: a Readonly Highlighted TextBlock in QTextEdit?

    To 2: 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.

  5. The following user says thank you to Lykurg for this useful post:

    vertusd (21st July 2010)

Similar Threads

  1. Replies: 3
    Last Post: 3rd September 2012, 07:32
  2. setVisible textblock in QTextEdit
    By corrado in forum Qt Programming
    Replies: 2
    Last Post: 27th April 2010, 03:04
  3. How to prevent an icon being highlighted?
    By Stobie in forum Qt Programming
    Replies: 1
    Last Post: 28th January 2010, 09:24
  4. Replies: 1
    Last Post: 5th August 2008, 13:53
  5. QomboBox - activated(), highlighted()
    By Salazaar in forum Newbie
    Replies: 10
    Last Post: 14th June 2007, 11:50

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.