×

Discussion Board

Results 1 to 15 of 15
  1. #1
    Registered User
    Join Date
    Nov 2008
    Posts
    15

    Fingerscrolling in QGraphicsView framework

    Hi!

    I have an application with following elements/ownership:

    QApplication->QMainWindow->QGraphicsView->QGraphicsScene->multiple QGraphicsItems

    The scene is bigger than the screen in N900, so I would like to enable FingerScrollable, but I don't seem to find the right place/way. I'm compiling in scratchbox with 4.6.0 18122009 version and have the same version on N900 as well. Hence there are no usable scrollbars (only the notification tiny ones) and scrolling with arrow keys work but fingerscrolling not. I have tried to put 'setProperty("FingerScrollable", true)' to QMainWindow class as well as to view and scene but with no luck.

    I know it works on certain other widgets, but how to enable it in QGraphicsView framework?

    >> Johannes <<

  2. #2
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Fingerscrolling in QGraphicsView framework

    Reference implementation:
    Code:
    #include <QApplication>
    #include <QGraphicsView>
    #include <QGraphicsScene>
    #include <QVariant>
    
    int main(int argc, char *argv[])
    {
        QApplication app(argc, argv);
    
        QGraphicsScene scene;
        scene.setSceneRect(0.0, 0.0, 1000.0, 1000.0);
        scene.addLine(0.0, 0.0, 1000.0, 1000.0);
        scene.addLine(1000.0, 0.0, 0.0, 1000.0);
    
        QGraphicsView view(&scene);
        if (!view.setProperty("FingerScrollable", true))
            qDebug("Setting FingerScrollable property failed");
        view.show();
    
        return app.exec();
    }
    FingerScrollable is property of QAbstractScrollArea area and it makes sense to set it only for objects of classes derived from QAbstractScrollArea.

  3. #3
    Registered User
    Join Date
    Nov 2008
    Posts
    15

    Re: Fingerscrolling in QGraphicsView framework

    Quote Originally Posted by divanov View Post
    Reference implementation:
    FingerScrollable is property of QAbstractScrollArea area and it makes sense to set it only for objects of classes derived from QAbstractScrollArea.
    I thought so myself, however your reference code did not work any better. Setting the property fails. Did it work for you? If so, what Qt version did you compile and run it on? Mine is currently 4.6.0-git20091218-0maemo1.

    >> Johannes <<

  4. #4
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Fingerscrolling in QGraphicsView framework

    Quote Originally Posted by kleimola View Post
    I thought so myself, however your reference code did not work any better. Setting the property fails. Did it work for you? If so, what Qt version did you compile and run it on? Mine is currently 4.6.0-git20091218-0maemo1.
    In fact that was for Qt 4.5.3. In Qt 4.6 FingerScrollable is true by default. Unfortunately I cannot try it with 4.6 right now. If it doesn't work then it's probably a bug in Qt 4.6.

  5. #5
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Fingerscrolling in QGraphicsView framework

    It would be nice to get an output of this application with Qt 4.6.
    Code:
    #include <QApplication>
    #include <QGraphicsView>
    #include <QGraphicsScene>
    #include <QVariant>
    #include <QDebug>
    
    int main(int argc, char *argv[])
    {
        QApplication app(argc, argv);
    
        QGraphicsScene scene;
        scene.setSceneRect(0.0, 0.0, 1000.0, 1000.0);
        scene.addLine(0.0, 0.0, 1000.0, 1000.0);
        scene.addLine(1000.0, 0.0, 0.0, 1000.0);
    
        QGraphicsView view(&scene);
    
        QVariant scrollable = view.property("FingerScrollable");
        if (scrollable.isValid()) {
            if (scrollable.toBool())
                qDebug("FingerScrollable property is set to true");
            else if (view.setProperty("FingerScrollable", true))
                qDebug("Setting FingerScrollable property succeed");
            else
                qDebug("Setting FingerScrollable property failed");
        } else
            qDebug("No FingerScrollable property found");
    
        view.show();
    
        return app.exec();
    }

  6. #6
    Registered User
    Join Date
    Nov 2008
    Posts
    15

    Re: Fingerscrolling in QGraphicsView framework

    Quote Originally Posted by divanov View Post
    It would be nice to get an output of this application with Qt 4.6.
    [/CODE]
    ~ $ run-standalone.sh ./FingerTest
    No FingerScrollable property found
    ~ $

    ...on the N900 device. I wonder if I'm missing some specific library i should know about or should the property be included in the libqt4-maemo5-gui?

    >> Johannes <<

  7. #7
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Fingerscrolling in QGraphicsView framework

    Quote Originally Posted by kleimola View Post
    ~ $ run-standalone.sh ./FingerTest
    No FingerScrollable property found
    ~ $

    ...on the N900 device. I wonder if I'm missing some specific library i should know about or should the property be included in the libqt4-maemo5-gui?

    >> Johannes <<
    You don't need run-standalone.sh launcher script on the device. But any way:
    http://qt.gitorious.org/qt/qt/blobs/...ea.cpp#line303

  8. #8
    Registered User
    Join Date
    Nov 2008
    Posts
    15

    Re: Fingerscrolling in QGraphicsView framework

    Quote Originally Posted by divanov View Post
    You don't need run-standalone.sh launcher script on the device. But any way:
    http://qt.gitorious.org/qt/qt/blobs/...ea.cpp#line303
    What does that tell you? It is only defined for Windows environment, but that gives the same result for me? I've seen it working on the device with normal widgets. Can you explain a bit?

    >> Johannes <<

  9. #9
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Fingerscrolling in QGraphicsView framework

    Quote Originally Posted by kleimola View Post
    What does that tell you? It is only defined for Windows environment, but that gives the same result for me? I've seen it working on the device with normal widgets. Can you explain a bit?

    >> Johannes <<
    Yeah, I didn't notice Q_WS_WIN define check at first glance...
    There is no FingerScrollable property and from the source it looks like panning with gestures enabled by default. It requires some debugging to figure out what has changed in 4.6 API.

  10. #10
    Registered User
    Join Date
    Nov 2008
    Posts
    15

    Solved: Fingerscrolling in QGraphicsView framework

    Quote Originally Posted by divanov View Post
    Yeah, I didn't notice Q_WS_WIN define check at first glance...
    There is no FingerScrollable property and from the source it looks like panning with gestures enabled by default. It requires some debugging to figure out what has changed in 4.6 API.
    Found the reason from http://forums.internettablettalk.com...82&postcount=5 and Kate's presentation. FingerScrollable property is only for Qt 4.5. In 4.6 you will have to use QMaemo5KineticScrolling which worked for QGraphicsView. You need to install 'apt-get qt4-maemo5-maemo5' on N900 as well. However, enabling kinetic caused mousepress and item dragging to get screwed up, so hopefully they will fix that somehow. I'd need the ability to both scroll a large scene and select&drag items in it...or get back the normal scrollbars in Qt for maemo...

    >> Johannes <<

  11. #11
    Registered User
    Join Date
    Nov 2008
    Posts
    15

    Re: Solved: Fingerscrolling in QGraphicsView framework

    Quote Originally Posted by kleimola View Post
    I'd need the ability to both scroll a large scene and select&drag items in it...or get back the normal scrollbars in Qt for maemo...
    Sometimes simple things work best. Instead of FingerScroll property or Maemo5 specific kinetic library (for this purpose), the following basic things work like charm on Maemo5 and Qt4.6 tp2.

    Code:
    view->setDragMode(QGraphicsView::ScrollHandDrag);
    QApplication::setOverrideCursor(Qt::ArrowCursor);
    The second line is to override the default open hand/closed hand cursor used by ScrollHandDrag on platforms that show the cursor. Maemo5 Qt4.6 tp2 seems to leave the cursor hidden by default, just like defining
    Code:
    QApplication::setOverrideCursor(Qt::BlankCursor);

  12. #12
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Fingerscrolling in QGraphicsView framework

    Sample code:
    Code:
    #include <QApplication>
    #include <QMaemo5KineticScroller>
    #include <QGraphicsView>
    #include <QGraphicsScene>
    #include <QPen>
    
    int main(int argc, char *argv[])
    {
        QApplication app(argc, argv);
    
        /* In theory default pen should be visible on the dark background */
        QPen pen(QColor(255, 255, 255, 255));
        QGraphicsScene scene;
    
        scene.setSceneRect(0.0, 0.0, 1000.0, 1000.0);
        scene.addLine(0.0, 0.0, 1000.0, 1000.0, pen);
        scene.addLine(1000.0, 0.0, 0.0, 1000.0, pen);
    
        /* QGraphicsView::alignment is Qt::AlignCenter by default, but scene still
           is not centered in view */
        QGraphicsView view(&scene);
        QMaemo5KineticScroller scroll(&view);
    
        view.show();
    
        return app.exec();
    }

  13. #13
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Fingerscrolling in QGraphicsView framework

    Some updates: http://labs.trolltech.com/blogs/2010...-5-going-beta/
    Kinetic Scrolling now default for all QAbstractScrollArea and QWebView based widgets.
    QMaemo5KineticScroller is not needed anymore and was removed.

  14. #14
    Registered User
    Join Date
    Nov 2008
    Posts
    15

    Re: Fingerscrolling in QGraphicsView framework

    Quote Originally Posted by divanov View Post
    Some updates: http://labs.trolltech.com/blogs/2010...-5-going-beta/
    Kinetic Scrolling now default for all QAbstractScrollArea and QWebView based widgets.
    QMaemo5KineticScroller is not needed anymore and was removed.
    Yes, but it is not working properly yet with QGraphicsView in this case (see qt-maemo-feedback@trolltech.com mailinglist from January 2010 and bug QTBUG-7761 which I just reported). The scene is being scrolled but kinetic scrolling clutters item selection and dragging. To disable the QAbstractKineticScroller for the time being you need to write something like

    Code:
    #include <QAbstractKineticScroller> 
    ..
    QAbstractKineticScroller *scroller;
    scroller = view->property("kineticScroller").value<QAbstractKineticScroller *>();
    scroller->setEnabled(false);

  15. #15
    Registered User
    Join Date
    Nov 2008
    Posts
    15

    Re: Fingerscrolling in QGraphicsView framework

    Some updates. Since version 4.6.2~git20100210-0maemo1 they have changed so far three things as reported by Robert Griebl:

    1) The kinetic scroller is attached, but disabled for QGraphicsView by default
    2) Kinetic scrolling will not start if a dragMode() ist set
    3) Kinetic scrolling will not start on Movable items

    Seems to work ok so far. The status of this bug/feature can be followed from below link

    http://bugreports.qt.nokia.com/browse/QTBUG-7761

Similar Threads

  1. Serialization Framework for CLDC
    By phibo in forum Mobile Java General
    Replies: 1
    Last Post: 2006-11-08, 20:02
  2. Help required inusage of HTTP over TLS framework in series 60 SDK
    By nkhanna1979 in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2005-11-27, 05:57
  3. Issue in using HTTP client framework on series 60 SDK
    By nkhanna1979 in forum Mobile Java Networking & Messaging & Security
    Replies: 0
    Last Post: 2005-11-25, 06:33
  4. regarding connectivity framework
    By flicker82 in forum Bluetooth Technology
    Replies: 7
    Last Post: 2004-10-27, 08:01

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×