Not painting
-
I have a widget (SelectRect) that (I am fairly sure) is on top of another widget that displays an image
The top widget uses:
setAttribute(Qt::WA_TransparentForMouseEvents); setAttribute(Qt::WA_NoSystemBackground); setAttribute(Qt::WA_WState_ExplicitShowHide);
and the Image display widget drives the mouseEvent handlers of the top level widget.
Both of those widgets are displayed in the central area of a QMainWindow.
There's also a docked dock widget.
When I first load an image and click on it the mousePressEvent of the top window is driven which in turn calls update() to drive paintEvent(). I have qDebug() code in the paintEvent code so I know the rectangles I want are being drawn.
Unfortunately, when this code is run the stuff drawn in paintEvent is not visible. If I then undock the dock widget, or just move the bar to change the size of the dock widget, the paintEvent stuff suddenly appears and I have no further problems...
First pass before sizing the dock widget - when I left mouse click in the image I get this:
After resizing the dock widget when I left click in the image I get this - which is what I expected to see above:
I am baffled!
The code for selectrect.cpp and .h is here:
https://www.dropbox.com/s/muw9p27coiuwcxp/selectrect.zip?dl=1
Thanks in advance
David -
@Axel-Spoerl Found it!! (At least I think so)
I needed to change SelectRect::rectButtonPressed() so that it ended with:
show(); raise(); activateWindow(); }
-
Hi David,
There's also a docked dock widget.
When I first load an image and click on it the mousePressEvent of the top window is driven which in turn calls update() to drive paintEvent(). I have qDebug() code in the paintEvent code so I know the rectangles I want are being drawn.Just to be sure:
From the window handle, it looks as if "Registering and Stacking" on the left is the dock widget.
The widget on the right is where the rectangles are being drawn, but not shown (I'll call it Sky-Widget)
When you undock the dock widget or resize the main window, the rectangles suddenly show up on the Sky-Widget.stuff drawn in paintEvent is not visible
I have a widget (SelectRect) that (I am fairly sure) is on top of another widget that displays an image
I can't download anything from dropbox, so I don't know the code of SelectRect. But from the name, I would guess that a new SelectRect is instantiated each time the user draws a rectangle.
So here's a a poke in the dark:- The initial Z-order of Sky-Widget and SelectRect doesn't reflect what should be shown. The rectangles are in the background or even hidden (
qDebug() << __FUNCTION__ << isVisible();
at the end ofpaintEvent
will tell). - There is a code path somewhere in the application source, that sets the Z-order right. That code path is not entered after the rectangles have been drawn.
- The Z-order code path is, however, entered when the main window consumes an
updateEvent
: That's the case when it's being resized or the dock widget is undocked. - Once the Z-order is correct, there are no more problems (Z-orders do not change automagically...).
=> somewhere in the code
QWidget::show()
orQWidget::raise()
is probably called on SelectRect.
Throwing a few qDebugs into the neighborhood may bring some more insight.Cheers
Axel - The initial Z-order of Sky-Widget and SelectRect doesn't reflect what should be shown. The rectangles are in the background or even hidden (
-
@Axel-Spoerl There are two dock widgets - the one on the left and the list of images at the bottom.
SelectRect is instantiated at the same time as the ImageView control (which displays the picture) When you click on an image in the list at the bottom it is loaded into the ImageView instance. When that completes the following code is run (in the case of interest rectAction->isChecked() will be true).
if (pToolBar->rectAction->isChecked()) { editStarsPtr->rectButtonPressed(); selectRectPtr->rectButtonPressed(); } void EditStars::rectButtonPressed() { // // No longer interested in signals from the imageView object // imageView->disconnect(this, nullptr); imageView->clearOverlay(); hide(); } void SelectRect::rectButtonPressed() { qDebug() << __FUNCTION__; connect(imageView, SIGNAL(Image_mousePressEvent(QMouseEvent*)), this, SLOT(mousePressEvent(QMouseEvent*))); connect(imageView, SIGNAL(Image_mouseMoveEvent(QMouseEvent*)), this, SLOT(mouseMoveEvent(QMouseEvent*))); connect(imageView, SIGNAL(Image_mouseReleaseEvent(QMouseEvent*)), this, SLOT(mouseReleaseEvent(QMouseEvent*))); connect(imageView, SIGNAL(Image_resizeEvent(QResizeEvent*)), this, SLOT(resizeMe(QResizeEvent*))); raise(); show(); update(); }
I plastered the code with
qDebug() << __FUNCTION__ << " visible " << isVisible();
and got lots of output like:
DSS::SelectRect::mousePressEvent visible true LMB pressed DSS::SelectRect::modeFromPosition visible true Selection mode 1 DSS::SelectRect::paintEvent visible true
Can you pull files from github? If so you can look at the the source of selectrect.cpp here:
https://github.com/deepskystacker/DSS/blob/release/DeepSkyStacker/selectrect.cpp
Thanks, David
-
@Perdrix
Hi David,
had a brief look at the class, but there's nothing that screams to me right away.
It would require some debugging of the entire application, to isolate the issue.
But since it's quite large and not a CMake project that I could just open with Qt Creator, I fear that this one goes beyond the scope of this forum.
Maybe someone else spots what I seem to miss.
Cheers
Axel -
@Axel-Spoerl The plot thickens - I now have reports of only 2 or 3 sides of the drawn rectangle(s) being visible.
So I am beginning to smell a video driver issue. What do you think.
I have an Intel P360 and nVidia RTX5000. I'm not sure which adapter is in charge here.
-
@Perdrix
Hi David,
The video driver could be one issue, XCB as well.
I have seen weird situations where XCB events were handled in the wrong order.
Brgds
Axel -
@Axel-Spoerl XCB? What's that?
-
@Axel-Spoerl Found it!! (At least I think so)
I needed to change SelectRect::rectButtonPressed() so that it ended with:
show(); raise(); activateWindow(); }
-