Embedding custom QWidgets inside a QTextEdit
-
wrote on 9 Oct 2015, 19:52 last edited by kfkf 10 Sept 2015, 19:53
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! -
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 ?
-
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 ?
wrote on 9 Oct 2015, 20:20 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. -
What kind of widget would you like to embed ?
-
wrote on 9 Oct 2015, 20:28 last edited by kfkf 10 Sept 2015, 20:29
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
oros.listdir
with a widget). -
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
-
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
wrote on 10 Oct 2015, 08:27 last edited byThanks @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!
-
One alternative might be to implement a QAbstractTextDocumentLayout
1/8