Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Little windows with QGraphicsView
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!
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.
Asperamanca last edited by
I would say m_pImageViewer becomes visible before you reach this line:
Until that line, it is created as a top-level window.
this->m_pImageViewer = new imageView(false);
This gives it NULL as parent and it becomes window as @Asperamanca says.
this->m_pImageViewer = new imageView(this);
Thank you very much for your answers. I tried with your idea, but the window keeps comming up.
try insert it into layout just after
this->m_pImageViewer = new ~~imageView(false);~~imageView(true);
@mrjj Ouch! If I do that, the QGraphicsView is put out of the layout:
But, the little window doesn't appear.
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.
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
hmm my best guess is that you forget to forward the parent in your subclass
imageView::imageView(QWidget* parent) : BaseClass(parent) <<< give to base class in ctor
BaseClass being the actual baseclass name .