Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Qt crashes when having a dropshadow and opacity effect set to widgets
Forum Updated to NodeBB v4.3 + New Features

Qt crashes when having a dropshadow and opacity effect set to widgets

Scheduled Pinned Locked Moved Unsolved Qt for Python
1 Posts 1 Posters 368 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TheGrudge
    wrote on last edited by
    #1

    Hi,

    I have a container widget with an opacity effect assigned to it, and a child widget that contains QToolButtons. This child has a dropshadow effect applied to it.

    The opacity effect is used for fading the widget in / out. It works fine without the dropshadow effect, but with it, it crashes as soon as I hover over a toolbutton.

    This is my widget code:

    class MapWidget(QgsMapCanvas):
    
        def __init__(self, parent=None):
            super().__init__(parent)
    
            self.legend = LegendWidget(self)
            self._showLegend = True
    
            self.controls = MapControlsWidget()
            self.controlsContainer = QWidget(self)
            layout = QVBoxLayout()
            layout.setContentsMargins(0, 0, 0, 0)
            layout.addWidget(self.controls)
            self.controlsContainer.setLayout(layout)
    
            self.controlsEffect = QGraphicsOpacityEffect(self)
            self.controlsEffect.setOpacity(0)
            self.controlsContainer.setGraphicsEffect(self.controlsEffect)
            self.controlsOpacityAnimation: QPropertyAnimation = None
    
            self.dropShadow = QGraphicsDropShadowEffect(self)
            self.dropShadow.setOffset(1)
            self.dropShadow.setBlurRadius(4)
            self.controls.setGraphicsEffect(self.dropShadow)
    
            self.controls.targetButton.clicked.connect(self.onTargetButtonClicked)
            self.controls.zoomInButton.clicked.connect(self.onZoomInButtonClicked)
            self.controls.zoomOutButton.clicked.connect(self.onZoomOutButtonClicked)
    
        def onTargetButtonClicked(self) -> None:
            if self.layers():
                self.zoomToSelected(self.layers()[0])
    
        def onZoomInButtonClicked(self) -> None:
            self.zoomIn()
    
        def onZoomOutButtonClicked(self) -> None:
            self.zoomOut()
    
        @pyqtProperty(bool)
        def showLegend(self) -> bool:
            return self._showLegend
    
        @showLegend.setter
        def showLegend(self, value: bool) -> None:
            self._showLegend = value
            self.legend.setVisible(value)
    
        def resizeEvent(self, e):
            super().resizeEvent(e)
            self.controlsContainer.setGeometry(
                QRect(self.width() - self.controls.width() - 10, 10, self.controls.width(), self.controls.height())
            )
    
        def enterEvent(self, *args, **kwargs):
            super().enterEvent(*args, **kwargs)
    
            self.controlsOpacityAnimation = QPropertyAnimation(self.controlsEffect, b"opacity")
            self.controlsOpacityAnimation.setDuration(350)
            self.controlsOpacityAnimation.setStartValue(0)
            self.controlsOpacityAnimation.setEndValue(1)
            self.controlsOpacityAnimation.setEasingCurve(QEasingCurve.OutBack)
            self.controlsOpacityAnimation.start(QPropertyAnimation.DeleteWhenStopped)
    
        def leaveEvent(self, *args, **kwargs):
            super().leaveEvent(*args, **kwargs)
    
            self.controlsOpacityAnimation = QPropertyAnimation(self.controlsEffect, b"opacity")
            self.controlsOpacityAnimation.setDuration(350)
            self.controlsOpacityAnimation.setStartValue(1)
            self.controlsOpacityAnimation.setEndValue(0)
            self.controlsOpacityAnimation.setEasingCurve(QEasingCurve.InBack)
            self.controlsOpacityAnimation.start(QPropertyAnimation.DeleteWhenStopped)
    
    

    Am I doing something wrong? I don't understand why it is crashing when hovering over a button.

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved