Results 1 to 5 of 5

Thread: QTextEdit not changing CharFormat.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2019
    Posts
    8
    Thanks
    5
    Qt products
    Qt5
    Platforms
    Windows

    Question QTextEdit not changing CharFormat.

    So, I'm trying to add an outline into a QTextEdit via CharFormat. For some reason, I can't seem to get the format to actually apply.
    Let me go through some things I've tried.


    This doesn't change current nor future text, even when I do set it to select everything, or try different cursor positions.
    Qt Code:
    1. outline.setTextOutline(QPen(Qt::black, 2));
    2. QTextEdit->mergeCurrentCharFormat(outline);
    To copy to clipboard, switch view to plain text mode 


    This is about the point where I started getting desperate, so I tried to instead simulate an outline via setting text-shadow on the stylesheet.
    Qt Code:
    1. QTextEdit->setStyleSheet("text-shadow: 0px 2px #000000, 0px -2px #000000, -2px 0px #000000, 2px 0px #000000")
    To copy to clipboard, switch view to plain text mode 
    Even though I've both tried to do this standalone and tried adding it on top of other stylesheet changes that were functioning via
    Qt Code:
    1. style.append("; text-shadow: 0px 2px #000000, 0px -2px #000000, -2px 0px #000000, 2px 0px #000000;");
    To copy to clipboard, switch view to plain text mode 
    it does not actually do anything either.



    The only way I've been to apply a charformat to a QTextEdit on my code was doing it alongside an insertText operation, which was
    Qt Code:
    1. QTextEdit->textCursor().insertText(qstring, qtextcharformat);
    To copy to clipboard, switch view to plain text mode 
    but I'd rather not rework this code to use insertText on this QTextEdit I want to change just so I can set an outline.
    Last edited by UriTK; 13th April 2019 at 01:23. Reason: reformatted to look better

Similar Threads

  1. CharFormat how set backgroud color ??
    By Pablik in forum Qt Programming
    Replies: 6
    Last Post: 25th July 2012, 08:15
  2. How to get CharFormat from each char
    By Pablik in forum Qt Programming
    Replies: 2
    Last Post: 16th July 2012, 23:07
  3. changing a QTextEdit from a dll
    By hcetiner in forum Newbie
    Replies: 1
    Last Post: 23rd April 2010, 18:38
  4. Changing line height in QTextEdit (Qt4)
    By ultr in forum Qt Programming
    Replies: 0
    Last Post: 19th February 2010, 16:59

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.