Unsolved Little windows with QGraphicsView
-
Hello!
I have an application which has different QGraphicsView. When I start the application, small windows appear in a instant and then close. As many windows open as QGraphicsView I have. It's like the windows starts and then embedded in their containers.
Anyone knows how to fix it?
Thank you very much!
-
Hi,
Without seeing the code you are using to setup your view it's pretty much impossible to guess what might be happening.
-
Yes, sorry. This is the code:
this->m_pImageViewer = new imageView(false); connect(m_pImageViewer, &imageView::sendRoiToTree, this, &PresetTourConfig::setRoiToTree); connect(m_pImageViewer, &imageView::saveModifiedRoi, this, &PresetTourConfig::saveROIs); m_pImageViewer->scene->setSceneRect(0, 0, 640, 480); ... m_pImageViewer->item->setPixmap(QPixmap::fromImage(imageFunctions::putImage(*mat->getMat()))); ui->layoutLiveImage->addWidget(m_pImageViewer);
imageView is a reimplemented class of QGraphicsView.
This is the little window that appears:
And then it disappears and is embedded in the widget.
-
@ivanicy said in Little windows with QGraphicsView:
m_pImageViewer
I would say m_pImageViewer becomes visible before you reach this line:
ui->layoutLiveImage->addWidget(m_pImageViewer);
Until that line, it is created as a top-level window.
-
@ivanicy said in Little windows with QGraphicsView:
this->m_pImageViewer = new imageView(false);
This gives it NULL as parent and it becomes window as @Asperamanca says.
try with
this->m_pImageViewer = new imageView(this); -
Thank you very much for your answers. I tried with your idea, but the window keeps comming up.
-
@ivanicy
hmm odd.
try insert it into layout just after
this->m_pImageViewer = new ~~imageView(false);~~imageView(true);
ui->layoutLiveImage->addWidget(m_pImageViewer);
.... -
@mrjj Ouch! If I do that, the QGraphicsView is put out of the layout:
But, the little window doesn't appear.
-
@ivanicy
argh, paste error !
don't use FALSE as a parent, its wrong!
use "this" or it becomes a window. -
@mrjj This false is a parameter, not the parent. I don't know why qt doesn't embed the layout in his position.
-
@ivanicy
normally its parent!
if u dont give parent its a window.
thats why it first show as small window before u insert into layout
please understand this, Any widget not given a parent will become window. -
@mrjj Yes, I understand, right now I have in the QGraphicsView constructor a boolean parameter and the parent, like this
this->m_pImageViewer = new imageView(false, this);
but the little window keeps coming up
-
@ivanicy
hmm my best guess is that you forget to forward the parent in your subclass
like
imageView::imageView(QWidget* parent) : BaseClass(parent) <<< give to base class in ctorBaseClass being the actual baseclass name .