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

Qt-interest Archive, March 2002
QCanvas


Message 1 in thread

In the process of designing a class for storing data that gets drawn on a
canvas, two possible design options occurred to me. Either this class can
have a member variable of type QCanvasItemList and store all items draw to
the canvas. OR, the class can just have the member variable of type
QCanvas - which keeps its own internal ItemList.

Each instance of these classes represents a different view (or canvas) in
the program. So essentially both are viable.

Any ideas on which one would be the better approach? Or, in other words,
which is the approach with QCanvas that applications are supposed to use?

Nicholas.


Message 2 in thread

Looks like maintaining your own list is redundant. In fact, it might be 
nothing more than a source of potential leaks.

The only reason I could see for keeping your own version is because you need 
them ordered a different way for performance reasons. In most cases I suspect 
this wouldn't be worth it.
-- 
 [ signature omitted ] 

Message 3 in thread

Hi.

I'm making a geographical map of the world, where pc are indicated via
circles. I'm currently using QCanvas/QCanvasView for this purpose.

My question is ... is QCanvas apropriate for the job ? I'd like to zoom
and still be able to plot pixels on a coordinate basis. eg. Currently 
I zoom to , say a scale of 10:1, what will hapen if I then draw a circle ?
Will it jump to the nearest 'background pixel', which is HUGE (and I think is 
actualy happening) or ... ?

Basicly I'm asking if QCanvas is suitable for cad like applications. 

Can I make an overlay ? Like a status bar / Logo , that is always displayed
in the same possition regardless of the zoom/translation ?


Thanks.
Reyn Vlietstra.


Message 4 in thread

On Mon, 18 Mar 2002, Reyn Vlietstra wrote:

> Hi.
>
> I'm making a geographical map of the world, where pc are indicated via
> circles. I'm currently using QCanvas/QCanvasView for this purpose.
>
> My question is ... is QCanvas apropriate for the job ? I'd like to zoom
> and still be able to plot pixels on a coordinate basis. eg. Currently
> I zoom to , say a scale of 10:1, what will hapen if I then draw a circle ?
> Will it jump to the nearest 'background pixel', which is HUGE (and I think is
> actualy happening) or ... ?
>
> Basicly I'm asking if QCanvas is suitable for cad like applications.

If you find the answer to this one let me know.  I tried using QCanvas to
plot graphs of several hundred thousand data points.. eahc point being a
QCanvas Item.. and the thing slowed to a crawl.

>
> Can I make an overlay ? Like a status bar / Logo , that is always displayed
> in the same possition regardless of the zoom/translation ?


Yes, you need to define a foreground pixmap/image and it will basically be
your 'hud' which is always drawn at maximum Z depth, meanint it overlays
everything.  Just make the parts you want to be transparent, transparent.


> >
> Thanks.
> Reyn Vlietstra.
>
> --
> List archive and information: http://qt-interest.trolltech.com
>


Message 5 in thread

This sounds like a dumb question ... but why is there a for
in the QCanvas::drawBackground() ?

for (int x=clip.x()/background->width();
  x<(clip.x()+clip.width()+background->width()-1)/background->width(); x++)
   {
   for (int y=clip.y()/background->height();
    y<(clip.y()+clip.height()+background->height()-1)/background->height(); 
y++)
	{
	  painter.drawPixmap(x*background->width(), 
                                         y*background->height(),*background);
	}
    }

This doesnt make sense to me :P (and it gets VERY slow when
zoomed in)

I overload the function and do the following:

  painter.drawPixmap(clip.x(), 
		     clip.y(),
		     *background, 
		     clip.x(),
		     clip.y(),
		     clip.width(),
		     clip.height()
		     );

This is quite a lot faster ... but I get a bit
of garbadge when zooming ... ?

Can someone explain this to me ?

Thanks
Reyn Vlietstra.