Results 1 to 2 of 2

Thread: QPlainTextEdit find a multiline text block

  1. #1
    Join Date
    Nov 2009
    Thanked 2 Times in 2 Posts
    Qt products

    Default QPlainTextEdit find a multiline text block

    Hello - I am creating a text editor for source code displayed in a QPlainTextEdit. I need to position the current text cursor at a block of text that may span several lines. Is there a way to use find() to locate text with several embedded newline characters? My test case is
    Qt Code:
    1. "ItemsEnableSet {\n MenuTag( 3220 )\n Enable( true )\n}"
    To copy to clipboard, switch view to plain text mode 
    . This is an exact match with a portion of the string in QPlainTextEdit and I can use simplify() on both strings to get a match (but then can't map back into the un-simplified string). I've tried creating a QRegularExpression with /S+ and .+ (with the dot match option enabled) and tried both find() and indexOf(). I can only match up to the first \n in the string. So I wonder if it's possible to match a multiline text? If it is possible can you give some insight on how to create the regular expression?

  2. #2
    Join Date
    Jan 2008
    Alameda, CA, USA
    Thanked 864 Times in 851 Posts
    Qt products

    Default Re: QPlainTextEdit find a multiline text block

    I've tried creating a QRegularExpression with /S+ and .+
    If you don't have it working yet, can you post your regular expression and the code where you use find()? I'll see if i can modify it to get it to work.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Issue with QPainter, opacity and multiline text
    By fsilva in forum Qt Programming
    Replies: 0
    Last Post: 3rd September 2018, 21:39
  2. Replies: 3
    Last Post: 27th July 2014, 10:50
  3. multiline text on QPainter
    By amitpatel22 in forum Qt Programming
    Replies: 3
    Last Post: 17th July 2011, 20:42
  4. Replies: 3
    Last Post: 5th February 2011, 07:31
  5. Multiline in QAction text
    By skimpax in forum Qt Programming
    Replies: 5
    Last Post: 15th October 2009, 17:58


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.