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

Search text in QPlainTextEdit

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 1.1k 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 27 Jun 2020, 03:22 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 27 Jun 2020, 06:38 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?

      J 1 Reply Last reply 27 Jun 2020, 07:06
      0
      • P PythonQTMarlem
        27 Jun 2020, 06:38

        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?

        J Offline
        J Offline
        JonB
        wrote on 27 Jun 2020, 07:06 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 27 Jun 2020, 10:21 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 27 Jun 2020, 11:02 last edited by
            #5

            solution:

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

            1/5

            27 Jun 2020, 03:22

            • Login

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