1

Encountered the following problem with rendering in QML. I have implemented the 'minimize window' button:

Image {
    source: "minimize.png"
    scale: mouse.pressed ? 0.8 : 1.0
    smooth: mouse.pressed

    MouseArea {
        id: mouse
        anchors.fill: parent
        anchors.margins: -5
        onClicked: {
            console.log("MinimizeButton clicked");
            viewer.showMinimized();
        }
    }
}

where 'viewer' is the object inherited from QDeclarativeView which represents the main application window. The button shrinks when user clicks the mouse onto it and window has been minimized. But button stays shrinked when window is restored. Tried to add the timer which prints 'mouse.pressed' every 1 sec:

Timer {
    repeat: true
    interval: 1000
    running: true
    onTriggered: {
        console.log("mouse.pressed =",mouse.pressed);
    }
}

It always prints mouse not pressed. But button is scaled to 0.8, not 1.0. "viewer.showMinimized()" appears to be guilty: button is rendered OK if it is commented out.

Any suggestions to solve the problem?

dc0
  • 151
  • 1
  • 6
  • The property mouse.pressed is only true for the short period when the mouse button is pressed, which is why your timer check will 'always' return false. The scale property of the image is affected by the mouse.pressed change, but you will only see the first change since the "false" case does not change the scale but merely sets it to the current value (1.0). Perhaps you can react to properties in QWidget instead, such as the property "minimized". – fejd Jun 22 '11 at 16:13
  • QGraphicsView (and inherited QDeclarativeView as well) stops responding to mouse clicks after window with Qt::FramelessWindowHint flag set is minimized via showMinimized() method. That's the problem. I still have not found the solution. – dc0 Jun 23 '11 at 01:52
  • Found workaround for this issue: http://developer.qt.nokia.com/forums/viewthread/7081/#42322 – dc0 Jun 28 '11 at 12:46

0 Answers0