[Interest] Widget doesn't receive mouse events...
Igor Mironchik
igor.mironchik at gmail.com
Wed May 13 14:48:24 CEST 2015
Hi guys,
I ran into a problem. I have one widget that do for itself QCamera
initialization, like this:
if( AppCfg::instance().cfg().cameraName() != d->cameraName )
{
d->cameraName = AppCfg::instance().cfg().cameraName();
if( d->camera )
{
disconnect( d->camera, 0, this, 0 );
disconnect( d->capture, 0, this, 0 );
delete d->camera;
d->camera = 0;
delete d->capture;
d->capture = 0;
}
d->camera = new QCamera(
AppCfg::instance().cfg().cameraName().toLatin1(),
this );
d->viewFinder = new QCameraViewfinder;
d->camera->setViewfinder( d->viewFinder );
d->capture = new QCameraImageCapture( d->camera, this );
d->capture->setCaptureDestination(
QCameraImageCapture::CaptureToBuffer );
d->camera->setCaptureMode( QCamera::CaptureStillImage );
emit cameraInitialized();
connect( d->camera, &QCamera::locked,
this, &CameraScreen::cameraLocked );
connect( d->capture, &QCameraImageCapture::imageCaptured,
this, &CameraScreen::imageCaptured );
connect( d->capture, &QCameraImageCapture::imageSaved,
this, &CameraScreen::imageSaved );
d->camera->start();
}
This widget has method that returns QCameraViewfinder:
QCameraViewfinder *
CameraScreen::cameraViewfinder() const
{
return d->viewFinder;
}
Another widget connected to the cameraInitialized() signal and do the
following in the slot:
void
CameraWidget::cameraInitialized()
{
if( d->stackedWidget->count() > 1 )
{
QWidget * viewfinder = d->stackedWidget->widget( 1 );
d->stackedWidget->removeWidget( viewfinder );
viewfinder->deleteLater();
}
d->stackedWidget->addWidget( d->cameraScreen->cameraViewfinder() );
}
So my problem is that that if I comment line:
d->stackedWidget->addWidget( d->cameraScreen->cameraViewfinder() );
then widget receives mouse events and work as expected, but when I
uncomment those line widget doesn't receive any mouse events and only
paint itself and that is all. QCameraViewfinder displays only black
rectangle...
What is the problem can be? Thank you.
P.S. I've checked that QCamera and QCameraViewfinder with this
initialization works. If I don't give parent-ship to the QStackedWidget
and invoke show() on QCameraViewfinder as top level window then
everything is ok. But when I pass QCameraViewfinder to my widget it
stops to receive mouse events and view finder doesn't display data from
my camera...
P.P.S. My widget has free area where QCameraViewfinder doesn't no
layouted, i.e. layout margins. And this area should receive mouse events
but it doesn't. Mouse events transmits to the another widget that under
my widget. And one more word about my widget: this is panel on top of
the another UI that can be moved by mouse, i.e pullout panel...
More information about the Interest
mailing list