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. Adding new functionality to CodeEditor example
QtWS25 Last Chance

Adding new functionality to CodeEditor example

Scheduled Pinned Locked Moved Solved General and Desktop
qtexteditqt5c++qwidget
4 Posts 2 Posters 211 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.
  • K Offline
    K Offline
    Khamza
    wrote on 11 Dec 2024, 17:55 last edited by
    #1

    I've seen example of creating line numbers using QPlainTextEdit from here. But now i also want to draw lines between strings. My idea was to override CodeEditor::paintEvent(). So the question is: can i call - QPlainTextEdit::paintEvent() from CodeEditor::paintEvent() to save QPlainTextEdit::paintEvent() functionality and then draw lines in it?
    If not, what is the best way to achieve this?

    J 1 Reply Last reply 11 Dec 2024, 17:59
    0
    • K Khamza
      11 Dec 2024, 17:55

      I've seen example of creating line numbers using QPlainTextEdit from here. But now i also want to draw lines between strings. My idea was to override CodeEditor::paintEvent(). So the question is: can i call - QPlainTextEdit::paintEvent() from CodeEditor::paintEvent() to save QPlainTextEdit::paintEvent() functionality and then draw lines in it?
      If not, what is the best way to achieve this?

      J Offline
      J Offline
      JonB
      wrote on 11 Dec 2024, 17:59 last edited by
      #2

      @Khamza
      Yes, assuming you mean CodeEditor inherits QPlainTextEdit. From your overridden paintEvent() call the base one and then you could add your own extra drawing, if that is what you want to do.

      K 1 Reply Last reply 11 Dec 2024, 18:06
      1
      • J JonB
        11 Dec 2024, 17:59

        @Khamza
        Yes, assuming you mean CodeEditor inherits QPlainTextEdit. From your overridden paintEvent() call the base one and then you could add your own extra drawing, if that is what you want to do.

        K Offline
        K Offline
        Khamza
        wrote on 11 Dec 2024, 18:06 last edited by
        #3

        @JonB Yeah, it is. But i read that i should not call paintEvent() directly. Isn't this the case?

        J 1 Reply Last reply 11 Dec 2024, 18:20
        0
        • K Khamza
          11 Dec 2024, 18:06

          @JonB Yeah, it is. But i read that i should not call paintEvent() directly. Isn't this the case?

          J Offline
          J Offline
          JonB
          wrote on 11 Dec 2024, 18:20 last edited by JonB 12 Nov 2024, 18:21
          #4

          @Khamza
          You are not supposed to just call paintEvent() from somewhere else, it's designed to be called during actual painting. If you override a base paintEvent() you can (and should) indeed call the base implementation from there.

          1 Reply Last reply
          3
          • K Khamza has marked this topic as solved on 11 Dec 2024, 18:27

          4/4

          11 Dec 2024, 18:20

          • Login

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