Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Embedding custom QWidgets inside a QTextEdit

    General and Desktop
    qtextedit qt4 pyqt4
    2
    8
    2843
    Loading More Posts
    • 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
      kfkf last edited by kfkf

      Hi, I'm working on the QtConsole and I've searched wide and high to a solution to this problem, and came up empty handed.
      This feature is of a really high importance to me, and I've wasted many hours on finding a solution to it, the closest I've got is QTextObject - but with no real-life examples and pretty shaky API I don't have an idea how to approach the implementation.

      Can anyone point me to the right direction? Is it even possible?
      Thanks!

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi and welcome to devnet,

        If you have a design like the Kate Editor in mind, the console is outside the editing widget which seems to be the best design.

        If not, what do you have in mind ?

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

        K 1 Reply Last reply Reply Quote 0
        • K
          kfkf @SGaist last edited by

          @SGaist Hi SGaist, I'm working on the QtConsole, which is a "Qt-based console for working with Jupyter(IPython) kernels".
          It's emulating a console with a QTextEdit widget, which works really well - but I would like to embed custom QWidgets inside the console, which means inside the QTextEdit widget.

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            What kind of widget would you like to embed ?

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

            K 1 Reply Last reply Reply Quote 0
            • K
              kfkf @SGaist last edited by kfkf

              I left it open(QWidget) as I'm looking for a generic solution, but if an example can help - my first priority is a QTableView and QTreeView(think about visualizing the results of ls or os.listdir with a widget).

              1 Reply Last reply Reply Quote 0
              • SGaist
                SGaist Lifetime Qt Champion last edited by

                For the table part, you should be able to do that directly with QTextEdit with help of html or the QTextDocument API.

                Otherwise you might have to use a layout + multiple QTextEdit/QWidget in a QScrollArea.

                Another alternative might be the Graphics View framework

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

                K 1 Reply Last reply Reply Quote 0
                • K
                  kfkf @SGaist last edited by

                  Thanks @SGaist, I wasn't aware of QTextTable, which seems as a reasonable solution(but still we'll have to implement the sort and search which comes for free with the QTableView).

                  About multiple QTextEdit/QWidgets in a QScrollArea, besides being a bit frustrating that it's the best solution, it's actually the closest I've seen, so thank you very much!

                  1 Reply Last reply Reply Quote 0
                  • SGaist
                    SGaist Lifetime Qt Champion last edited by

                    One alternative might be to implement a QAbstractTextDocumentLayout

                    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 Reply Quote 0
                    • First post
                      Last post