Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 2

Qt-interest Archive, September 2002
Re: Designing custom QCanvasItems - feedback requested!


Message 1 in thread

On Thu, 2002-08-29 at 12:08, Erik Arner wrote:
> Hi,
> 
> I'm constructing an app which draws and manipulates items on a QCanvas.
> If someone is interested in giving me some feedback on the item classes
> I'd be grateful, since I'm a newbie in the GUI and Qt department.
> 
> The app is a text string alignment tool (well, it's actually a DNA
> alignment tool but "text string" is a good enough abstraction). There
> will be different kinds of sequences/items present on the canvas, where
> some properties are shared by the items. For instance, common for all
> sequences is that the graphical representation will be different at
> different zoom levels - when zoomed out, the items will appear as
> lines/bars (i.e. QCanvasLine).
...

I think you should reconsider your approach for two reasons.

You have to have the idea of how much pixels are usable
for each string to implement resolution dependant data
representation.
You have to draw very different things depending on
hort lifed user actions (zooming).

The problem of assigning portions of the available screen
   space to different parts is already addressed by "layout
   management". See the Qt Manual or even a manual about 
   programming with the Motif Toolkit.

You could easily run into trouble by constructing and destructing
   many QCanvasItems back and forth (slow) or by creating them
   all in advance (memory consumption). Painting some 2D Graphics
   into a window could be faster and smaller.

Of course Qcanvas has its merits. For example if you are going
to make the display responsive to mouse actions (QCanvas::collisions).
But again: it isn't that complicated to map a mouse click to
the data object you painted. Especially if the data is one-dimensional
in its natur like DNA strings are.

All in all you maybe should think of implementing your own
widget that shows a single string and put some more of them
into a QGrid of QScrollViews or something appropriate.

-- 
 [ signature omitted ]