Qt-interest Archive, May 2007
QScrollArea - how to access events?
Message 1 in thread
I've created a data-image display system that is based on QGLWidget
which pops up a stand-alone window containing the image. The size
of the pseudo-image (i.e. derived from the data) is determined after
the data is read in.
class DataDisplay : public QGLWidget
....
void DataDisplay::Setup(QString FileName)
{
GetData(FileName);
resize(nImageXdim,nImageYdim);
show();
}
which works very nicely. I have a number of event handlers that
deal with keyboard, mouse, move, resize and close events.
I need to deal with the situation where either 1) the image size is
greater than the screen size or 2) the image is zoomed to greater
than the screen size.
I tried embedding a QScrollArea in my code:
void DataDisplay::Setup(QString FileName)
{
GetData(FileName);
imageScroll = new QScrollArea();
imageScroll->setWidget(this);
imageScroll->setBackgroundRole(QPalette::Dark);
resize(nImageXdim,nImageYdim);
imageScroll->resize(nImageXdim+5,nImageYdim+5);
// this last seems to be necessary so that the image frame matches
// the size of the image and only adds a scroll bar when the image
// has exceeds the screen size - is there a better way to do this?
.........
and that works, up to a point - but, of course, now all events such as
keyboard, move, etc. are sent to the QScrollArea and not to my original
class - so how to access them? There seems to be a viewportEvent in
the base class, but I'm not sure how how to use this.
DS
Be smarter than spam. See how smart SpamGuard is at giving junk email the boot with the All-new Yahoo! Mail at http://mrd.mail.yahoo.com/try_beta?.intl=ca
--
[ signature omitted ]