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

Adding new functionality to CodeEditor example

Scheduled Pinned Locked Moved Solved General and Desktop
qtexteditqt5c++qwidget
4 Posts 2 Posters 214 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 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?

    JonBJ 1 Reply Last reply
    0
    • K Khamza

      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?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on 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
      1
      • JonBJ JonB

        @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 last edited by
        #3

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

        JonBJ 1 Reply Last reply
        0
        • K Khamza

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

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #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

          • Login

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