[Development] AplicationWindow, QQuickWindow, contentRotation and setting width and height of contentItem

Tomasz Olszak olszak.tomasz at gmail.com
Thu Aug 1 23:53:36 CEST 2013


 Hi,

I would like to make POC of automatic rotation of ApplicationWindow's
contentItem.
It can be simple solution for devices which have accelerometer only and
don't have system screen rotation.

Following mockup works:

/*ApplicationWindow.qml*/

Window {

    id: root



    /* In the end some kind of boolean property will turn on/off
following bindings or use transform property - don't decided yet*/

     property bool contentItemFollowsContentOrientation: false



    property bool __isPortrait: contentOrientation ===
Qt.PortraitOrientation || contentOrientation ===
Qt.InvertedPortraitOrientation

    contentItem.x: __isPortrait ? 0 : root.width/2 - root.height/2

    contentItem.y: __isPortrait ? 0 : root.height/2 - root.width/2

    contentItem.width: __isPortrait ? root.width : root.height

    contentItem.height: __isPortrait ? root.height : root.width

    contentItem.rotation: (contentOrientation ==
Qt.LandscapeOrientation) ? 90 :

                          (contentOrientation ==
Qt.InvertedPortraitOrientation) ? 180 :

                          (contentOrientation ==
Qt.InvertedLandscapeOrientation) ? -90 : 0

    Rectangle {

        id: thisItemIsProperlyRotated

        anchors.fill:parent

    }

 }


but only for square windows :) because following code have significant
impact on behavior of contentItem.with and contentItem.height bindings:


void QQuickWindowPrivate::initContentItem()

{

    Q_Q(QQuickWindow);

    q->connect(q, SIGNAL(widthChanged(int)),

            contentItem, SLOT(setWidth(int)));

    q->connect(q, SIGNAL(heightChanged(int)),

            contentItem, SLOT(setHeight(int)));

    contentItem->setWidth(q->width());

    contentItem->setHeight(q->height());

}


Shouldn't bindings be created instead of connections or maybe it was done
on purpose?
Do you see any risks of adding such feature?

-- 
regards,
Tomasz Olszak
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20130801/b27f2b1e/attachment.html>


More information about the Development mailing list