Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. Some issues with QTextEdit (PySide2)
Forum Updated to NodeBB v4.3 + New Features

Some issues with QTextEdit (PySide2)

Scheduled Pinned Locked Moved Unsolved Language Bindings
3 Posts 2 Posters 994 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.
  • K Offline
    K Offline
    kvutza
    wrote on last edited by
    #1

    Hi,

    • when setting self.setAlignment(QtCore.Qt.AlignRight) on a QTextEdit instance, then setting <an_extra_selection>.format.setProperty(QtGui.QTextFormat.FullWidthSelection, True) does not put that extra selection over whole line (like when you do current-line highlighting).

    • following movements of cursor by setting self.cursorPositionChanged.connect(self.<method_for_line_highlighting>) does not suffice, since doing select-all action (by Ctrl-A) moves the text cursor (putting it to the text end) without triggering the signaling. It is necessary to follow the selectionChanged signaling too.

    I'm using PySide2 under Ubuntu 16.04, Python3:

    import PySide2
    PySide2.__ version_info __
    (2, 0, 0, 'alpha', 0)

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

      Hi and welcome to devnet,

      You should provide a complete code example otherwise it's pretty much impossible to reproduce the behaviour you're describing.

      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
      2
      • K Offline
        K Offline
        kvutza
        wrote on last edited by
        #3

        Hi, I encountered it when developing a simple app. I was able to deal with it somehow, thus this is meant as a notice about these issues for Qt people.

        The missing signaling on select-all event can be seen by commenting out self.highlight_current_line() at (one of) def selection_changed(self): there.

        The issue with line highlighting of right-aligned lines can be seen by adding self.setAlignment(QtCore.Qt.AlignRight) at one of the QTextEdit-based classes, like at class CmdTextEdit(QTextEdit): e.g. just before self.setUndoRedoEnabled(True) by the end of its __init__:

        self.setAlignment(QtCore.Qt.AlignRight)
        self.document().setModified(False)
        self.setUndoRedoEnabled(True)

        with the self.document().setModified(False) being put there to convince Qt that this setting is still within initialization.

        BTW I've seen at the Qt example that line numbers are thought to be drawn by painters, though the painter did not want to work for me (complaining about something, may be about being not active, not sure now). And since I did not know how to convert that example onto partially-seen lines anyway, I did it a different way.

        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