×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Dec 2008
    Posts
    4

    Qt 4.6 QGraphicsView + Finger scroll + Mouse press

    Hi, I have a small problem with QGraphicsView in Qt 4.6 and Maemo5. It seems it has enabled finger (kinetic) scrolling by default and whenever I add new item to scene out of bounding box, it enlarges the view area. This isn't what I want. I don't want to have scroll enabled, so I set ScrollBarPolicies to ScrollBarAlwayOff, but it didn't help me and the finger scroll is still enabled.

    I can't find how to disable it, so I tried to set size of QGraphicsScene to size of display and this help a half. Now QGraphicsView isn't scrollable however it doesn't accept mouse press events, I have to do double click to emulate it.

    How can I disable the finger scroll and how to make QGraphicsView accept mousepress events? Thanks!

  2. #2
    Nokia Developer Moderator
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Qt 4.6 QGraphicsView + Finger scroll + Mouse press

    This is default behaviour of QGraphicsView and QGraphicsScene
    http://doc.trolltech.com/4.6/qgraphi...sceneRect-prop
    Note, that there is also sceneRect property of QGraphicsView, which defines the area of the scene visualized by view.
    http://doc.trolltech.com/4.6/qgraphi...sceneRect-prop

    Could you please give an explanation, what are you trying to achieve in terms of goals and maybe provide small test application?

  3. #3
    Registered User
    Join Date
    Dec 2008
    Posts
    4

    Re: Qt 4.6 QGraphicsView + Finger scroll + Mouse press

    Ok, so:

    1. I want QGraphicsView of fixed size (size of screen), without scrollbars and without scrollable. This is done by setting QGraphicsScenes sceneRect to size of display and it is ok now, it is showing objects only in this area.

    2. I want objects in QGraphicsScene to accept mousepresses (mousePressEvent), which works under linux and under maemo sdk, but on the real device (N900), I have to do double click to simulate mouse press. I think it is because of enabled kinetic scrolling...

    Sorry if you are confused, it's difficult for me explain my problem in english.

  4. #4
    Registered User
    Join Date
    Dec 2008
    Posts
    4

    Re: Qt 4.6 QGraphicsView + Finger scroll + Mouse press

    here is small example, try to click on the rect under linux and on the device:

    main.cpp:
    #include <QApplication>
    #include <QGraphicsView>
    #include <QGraphicsScene>
    #include "myobj.h"

    int main(int argc, char *argv[])
    {


    QApplication app(argc, argv);
    QGraphicsScene scene(QRectF(0,0,800,424));
    QGraphicsView view(&scene);
    MyObj obj;
    scene.addItem(&obj);
    view.show();
    return app.exec();

    }

    myobj.h:
    #ifndef MYOBJ_H
    #define MYOBJ_H

    #include <QGraphicsObject>

    class MyObj : public QGraphicsObject
    {
    public:
    MyObj();
    QRectF boundingRect() const;
    private:
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
    void mousePressEvent(QGraphicsSceneMouseEvent *event);
    };

    #endif // MYOBJ_H

    myobj.cpp:
    #include "myobj.h"
    #include <QPainter>
    #include <QGraphicsSceneMouseEvent>

    MyObj::MyObj()
    {
    }

    QRectF MyObj::boundingRect() const
    {
    return QRectF(0,0,50,50);
    }

    void MyObj:aint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
    {
    painter->drawRect(QRect(0,0,50,50));
    }

    void MyObj::mousePressEvent(QGraphicsSceneMouseEvent *event)
    {
    qDebug("Click");
    }

  5. #5
    Nokia Developer Moderator
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Qt 4.6 QGraphicsView + Finger scroll + Mouse press

    Quote Originally Posted by kuba.janda View Post
    here is small example, try to click on the rect under linux and on the device:
    I've tried. It works perfectly with Qt 4.6 I've installed from extras-devel:
    http://repository.maemo.org/extras-d.../q/qt4-maemo5/

  6. #6
    Registered User
    Join Date
    Dec 2008
    Posts
    4

    Re: Qt 4.6 QGraphicsView + Finger scroll + Mouse press

    I have to apologize. I didn't check version of qt libs installed on the device. After update it works perfectly. Thanks for help.

    Kuba J.

  7. #7
    Nokia Developer Moderator
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Qt 4.6 QGraphicsView + Finger scroll + Mouse press

    Quote Originally Posted by kuba.janda View Post
    I have to apologize. I didn't check version of qt libs installed on the device. After update it works perfectly. Thanks for help.

    Kuba J.
    But packages are far away from being perfect. There is a conflict with base-files package and I had to create symlinks manually.

  8. #8
    Nokia Developer Moderator
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Qt 4.6 QGraphicsView + Finger scroll + Mouse press

    Some test application, which doesn't have scrolls.
    scenes1.0.0.tar.gz

Similar Threads

  1. From where i can download Qt 4.6?
    By ScrewSomeOne in forum [Archived] Qt SDKs and Tools
    Replies: 6
    Last Post: 2012-07-06, 02:33
  2. Qt for Symbian development resources
    By liuxg in forum [Archived] Qt General ( Qt技术)
    Replies: 55
    Last Post: 2011-01-26, 04:06
  3. Senior QT Client Developer (Dublin, Ireland)
    By marynyc in forum News, Announcements and Job Listings
    Replies: 0
    Last Post: 2009-06-02, 18:24

Posting Permissions

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