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. QTextCharFormat tooltip
Qt 6.11 is out! See what's new in the release blog

QTextCharFormat tooltip

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 739 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.
  • F Offline
    F Offline
    Fuchsiaff
    wrote on last edited by
    #1

    I don't really understand how it should work
    Here's my code:

    for name, values in self.regex.items():
                self.formats[name] = QTextCharFormat()
    
                if name == "class":
                    self.formats[name].setFontWeight(QFont.Bold)
    
                elif name == "function":
                    self.formats[name].setFontItalic(True)
    
                elif name == "magic":
                    self.formats[name].setFontItalic(True)
                elif name == "F_bool":
                    self.formats[name].setToolTip("Hello world!"
    

    F_bool is a QTextCharFormat which matches the word "False" in my editor.
    When hovering over the word in the editor, is it supposed to show a tooltip?
    Because it isn't showing anything right now.

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

      Hi,

      What version of PyQt are you using ?
      On what platform ?
      Can you please provide a complete python example to test that ?

      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
      1
      • F Offline
        F Offline
        Fuchsiaff
        wrote on last edited by
        #3

        I'm using PyQt5 and I'm on Linux.

        I have a QPlainTextEdit which has a syntax highlighter on it and after searching google I found this stackoverflow question which is pretty recent:

        https://stackoverflow.com/questions/54046226/how-to-get-working-settooltip-from-qtextcharformat-inside-qsyntaxhighlighter

        I will give a working example that you can test tomorrow!

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

          What is the exact version of PyQt 5 that you are using ?
          Also, how did you installed it ?

          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