Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Best choice for a long String GUI handling?
I need to show information in my GUI. This is a very long String (a chromosome's nucleotid sequence: AGGCTATGCA....), thounsands of characters.
Also, I need to show several of these Strings aligned one under the other:
CHROMO 1 | ACGGTACCTAGAGCTTA
CHROMO 2 | ATGGTACCTAGAGCTTA
The user should select a column (He can select a "letter" position, the full column).
Whats the best Widget to show this long information and make some basic manipulation (select columns, replace some "letter" in a sequence..).
Thank you for your advices.
mcosta last edited by
for column selection I suggest you to use TableWidget or TreeWidget (depending of your app architecture you could use Views instead of Widgets).
Hi mcosta, thank you for your advice.
I ve already tried with my own TableView, but It causes a laggy performance. Maybe Tables are not designed for a such function, included TableWidget, isnt? TreeWidget is faster? I dunno if TreeWidget provides a confortable navigation for so long String. Mmm
bootchk last edited by
Use a SimpleText inside a View that scrolls? The SimpleText's QDocument will tell you what index (which you can convert to column with a little math) of the text a mouse click is in. Set the layout width of the Document so that it wraps at the length of the longer sequence. Sorry, I don't have the details.
Isn't there some other open source code that displays aligned sequences, from which you can get ideas?
Heya bootchk, and ty for your reply.
I've not understood what you mean with QDocument. Maybe several QTextEdit inside a QWidget, is that?
bootchk last edited by
(Sorry for the confusion. I use a QGraphicsScene. I should have said QGraphicsTextItem or QTextEdit instead of "simple text".) Both QGTI and QTextEdit are similar: they have a document() method to get the QTextDocument. That has a documentLayout() method to get a QTextLayout. That has a lineForTextPosition() method to get a line (at a cursor position). And so forth, you can determine the line and "column" in that line, where the user puts the visual cursor, or even using mouse event coords (as I recall.) The object model of the various classes (Document, Layout, etc) is not easy to understand, but it is not unusual, it has been used for a long time.
Ok, I use now a QTextEdit. I thought It's a better idea use just one QTextEdit, and every line (row) will be occuped for a chromosome. I setted Vertical Scroll as "always", but I cannot force an String to occupe only one line.
Ok, now I use lineWrapMode = no wrap.
My problem now is: how to set a new line: chromosomes are now written at the same line.
*Anyway: * QTextEdit is still low performance when I load more than 10 - 12 chromosomes. Some others applications, even if they seem a bit "old" in terms of GUI, can move this amount of data. Maybe another Widget faster?