Presenting horizontally scrollable text with label
-
PySide2, Qt5
I need to present genomic sequences which are very long (see image one). I have to present many of them. They are very similar, with a few differences (red characters, image 2).
Now I want a fixed label (left text field in image 1, "Seq....."). On the right the sequences are presented and are horizontally scrollable. The labels should always be shown in their full length. So no horizontal scrollbar on the label text field.
Image1:
Image 2, If I scroll horizontally it looks like this:
I have the following questions:
-
I implemented this with two QGraphicsScene widgets. Is this the right way to do it? Or would you tackle this problem in a different way? They are placed in the same layout by the way.
-
I want the two text fields to be "fused". So I want the same behaviour, but the gap in between should be gone. But the labels ("Seq...") have to be static in place.
-
I implemented zooming which works fine. One problem I have is that the left QGraphicsView will correctly increase its size when zooming in, but keep the width when zooming out and hence stay too big regarding width. I did it this way:
self.view_labels.setFixedWidth(self.view_labels.scene().width())
- As soon as I have fixed the problems above I want to make sure that both text fields are vertically scrollable if there is too much text in the right field which fits into the text field. So there should be one scrollbar on the right scrolling both text fields synchronously.
-
-
@MS_GX
I don't know whether you have a good reason for doing this via "two QGraphicsScene widgets"; you may have, perhaps for the zooming, perhaps for the column headers. I don't know about gfx scene widgets. But I will say the following, as possible food for thought.This looks like just a plain
QTableView
/QTableWidget
. That has "horizontal headers", which is what your label column is. You can have the non-header area horizontally scrollable, for the sequences. (You can also reduce the gap between label & data.) You can also vertically scroll that. The advantage is that you don't have to worry about "syncing" the vertical scroll between two separate vertical widgets, it will scroll both. You also get the "keep vertical column headers in place" when scrolling vertically.Or, there is the Frozen Column Example to do the label column as "frozen" in place in a different way, still in a
QTableView
.As I say, you'll have to investigate whether this would allow the operations you want on items.