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

scintilla

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
6 Posts 2 Posters 1.8k Views 1 Watching
  • 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.
  • G Offline
    G Offline
    gnoowami
    wrote on last edited by
    #1

    i use scintillaeditbase.h instead of textarea etc..
    So i want to show line number to use scintillaeditbase.h
    is there any options?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Do you mean https://qscintilla.com/ ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      G 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Do you mean https://qscintilla.com/ ?

        G Offline
        G Offline
        gnoowami
        wrote on last edited by
        #3

        @SGaist Yes i mean that!

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          From a quick check, it looks like you need to set the STYLE_LINENUMBER from Scintilla.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          G 1 Reply Last reply
          1
          • SGaistS SGaist

            From a quick check, it looks like you need to set the STYLE_LINENUMBER from Scintilla.

            G Offline
            G Offline
            gnoowami
            wrote on last edited by
            #5

            @SGaist i know this option, but i dont know how to use this option.
            I use scintillaeditbase.cpp and scintillaeditbase.h

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by SGaist
              #6

              I found a simpler way to do it, see the following:

              import pathlib
              import sys
              from PyQt5.QtGui import QFont, QFontMetrics, QColor
              from PyQt5.QtWidgets import QApplication
              from PyQt5.Qsci import QsciScintilla, QsciLexerPython
              
              
              class SimplePythonEditor(QsciScintilla):
                  def __init__(self, parent=None):
                      super().__init__(parent)
              
                      # Set the default font
                      font = QFont()
                      font.setFamily("Courier")
                      font.setFixedPitch(True)
                      font.setPointSize(10)
                      self.setFont(font)
              
                      # Margin 0 is used for line numbers
                      fontmetrics = QFontMetrics(font)
                      self.setMarginsFont(font)
                      self.setMarginWidth(0, fontmetrics.width("00000") + 6)
                      self.setMarginLineNumbers(0, True)
                      self.setMarginsBackgroundColor(QColor("#cccccc"))
              
                      lexer = QsciLexerPython()
                      lexer.setDefaultFont(font)
                      self.setLexer(lexer)
              
              
              if __name__ == "__main__":
                  app = QApplication(sys.argv)
                  editor = SimplePythonEditor()
                  editor.show()
                  editor.setText(pathlib.Path(sys.argv[0]).read_text())
                  sys.exit(app.exec())
              
              

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0

              • Login

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