Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Search text in QPlainTextEdit
Qt 6.11 is out! See what's new in the release blog

Search text in QPlainTextEdit

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 1.4k 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.
  • P Offline
    P Offline
    PythonQTMarlem
    wrote on last edited by
    #1

    hello,

    I'm developing a text editor with Python and Qt.
    now i want to search for text in a QPlainTextEdit ('').
    How do you program something like that?

    1 Reply Last reply
    0
    • P Offline
      P Offline
      PythonQTMarlem
      wrote on last edited by
      #2

      i found this:
      https://doc.qt.io/archives/4.6/uitools-textfinder.html

      but I can't rewrite it in Python. Can someone help please?

      JonBJ 1 Reply Last reply
      0
      • P PythonQTMarlem

        i found this:
        https://doc.qt.io/archives/4.6/uitools-textfinder.html

        but I can't rewrite it in Python. Can someone help please?

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #3

        @PythonQTMarlem
        If you want to copy that, you simply have to go through it line-by-line and translate the C++ into Python. Personally I don't think that's difficult, but your mileage may vary.

        now i want to search for text in a QPlainTextEdit ('').

        This is just https://doc.qt.io/qt-5/qplaintextedit.html#find. That will exist in PySide2/PyQt5.

        1 Reply Last reply
        2
        • P Offline
          P Offline
          PythonQTMarlem
          wrote on last edited by
          #4

          hi,

          i try. but now i don't know how to convert this in python:

          QTextCursor highlightCursor(document);
          QTextCursor cursor(document);
          

          I would appreciate a suggestion.

          1 Reply Last reply
          0
          • P Offline
            P Offline
            PythonQTMarlem
            wrote on last edited by
            #5

            solution:

            highlightCursor = QTextCursor(self.document)
            cursor = QTextCursor(document)
            
            1 Reply Last reply
            2

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved