Results 1 to 5 of 5

Thread: How to highlight differently two views of the same QTextDocument

  1. #1
    Join Date
    May 2015
    Posts
    3
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default How to highlight differently two views of the same QTextDocument

    Hello everyone !

    I found already a lot of answers on this forum, but I'm stuck on this issue :

    I'm trying to implement a sort of text "minimap" as we can find in Kate or Sublime Text (more the latter) .

    From a single QTextDocument, I display it in a QTextEdit (editor) and also in a QTextBrowser (minimap) . The minimap uses QGraphicsView and QGrapicsProxyWidget to be seen scaled down. It works fine.

    Now, I want to apply a different highlighting to each of the views. I read everywhere that I can't use two QSyntaxHighlighter in the same QTextDocument. Fine, having already use this class, I understand the limitation. Yet, I don't want to clone the QTextDocument each time there is an update, only for it to support it's own highlighter. It would be resource hungry with large texts.

    Does anyone have an idea ? Maybe a workaround or a different approach ? I'd like to read your input

    Thank you for your time and "Vive Qt !"

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to highlight differently two views of the same QTextDocument

    What exactly do you want to highlight differently? The whole text or do you mean selections?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    May 2015
    Posts
    3
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to highlight differently two views of the same QTextDocument

    Hello wysota,

    A whole different set of fonts and colors for all of the document.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to highlight differently two views of the same QTextDocument

    I'm afraid in that case you will have to make a copy of the document and synchronize both documents by handling QTextDocument::contentsChange() signal.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    May 2015
    Posts
    3
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to highlight differently two views of the same QTextDocument

    Thank you, I was afraid of that.

Similar Threads

  1. Replies: 3
    Last Post: 18th September 2013, 07:19
  2. Replies: 12
    Last Post: 7th August 2013, 14:15
  3. QPushButton appears differently
    By gianhut in forum Qt Tools
    Replies: 4
    Last Post: 5th January 2009, 23:08
  4. QPalette works differently on windows and linux
    By babu198649 in forum Newbie
    Replies: 3
    Last Post: 6th March 2008, 08:27
  5. Replies: 13
    Last Post: 18th February 2008, 01:20

Tags for this Thread

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.