[Qt-interest] I give up with qgraphicsscene and qgraphicsview, with stationary items
Jason H
scorp1us at yahoo.com
Wed Mar 24 02:17:33 CET 2010
I don't know how you would put one control on top of another...
I would impliment a Qwidget-derived class that would draw one QGV on top of the other. Maybe capturing the first as a pixmap? This would pass some events like the scroll events, etc, to the bottom, while filtering the click events first though the top QGV, and if not matching an item, then pass to the bottom QGV.
If at all possible, I'd dispense with the pixmap idea (it'll be laggy) and see if you can't redirect the paint() of the bottom into the top. But by having 2 QGVs you can scale and manage items independently in their own scenes/views. I'd call it a CompositeGraphicsView or a LayeredGraphicsView.
then have something like
QGraphicsScene *widget->layer(i)->scene(int index);
QGraphicsView *widget->layer(i)->view(int index);
So you could use it like
widget->layer(0)->scene()->addItem(...);
Then when it comes time to paint
LayeredGraphicsView::paint(...)
{
for (int i=layers.count(); i>=0; i--)
{
layers.at(i)->render(this->painter(), ...);
}
}
Which then should draw each QGV into the widget. Besure to set the QGVs background drawing to off.
----- Original Message ----
From: Gordon Schumacher <whiplash at pobox.com>
To: qt-interest <qt-interest at trolltech.com>
Sent: Tue, March 23, 2010 11:13:44 AM
Subject: Re: [Qt-interest] I give up with qgraphicsscene and qgraphicsview, with stationary items
On 3/23/2010 5:00 AM, Kari Laine <klaine8 at gmail.com> wrote:
> What I have been trying is to have fixed texts, lines and polylines in
> relation to view. So that user scrolls scene those items stay put in
> relation to view.
> I was able to get stationary lines with drawForeground. But those are
> QPainterPaths which are not moveable and you can not select them.
> Is it so?
>
> So basic thing is that one cannot have QGraphicsItems which would stay
> put when scene is scrolled. Could that be added to the QT?
>
Indeed, partially reiterating others' ideas... I can think of three options:
1) A transparent QGraphicsView that floats above the main QGraphicsView
2) Add scrollbars outside the QGraphicsView, make the items that are
meant to scroll children of a "container" item, and use the scrollbar
positions to change the translation of the container (look at the
example pictured in the Graphics View section, the one with the rotating
coordinate diagrams - alas, I don't remember its name)
3) Add a QScrollArea via a QGraphicsProxyWidget to the QGraphicsView for
the scrollable items
I haven't the faintest idea which of these would yield the best
performance, though; perhaps a Troll who's versed in GraphicsView could
chime in here? (Or ask on the #qt or #qt-labs IRC channels.)
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest
More information about the Qt-interest-old
mailing list