Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User romulovitor's Avatar
    Join Date
    Mar 2008
    Posts
    26
    I want to implement page panning by manipulating the graphics item. Using the example available on /opt/qt4-maemo5/examples/maemo5/maemobrowser/ it's pretty much straight forward. However, since ajax http request doesn't reload the page, in order to invoke resizeWebViewToFrame() I needed to connect to contentsSizeChanged signal and then set qgwebview geometry.

    connect(qgwebview->page()->mainFrame(), SIGNAL(contentsSizeChanged(QSize)), this, SLOT(mycontentsSizeChanged(QSize)));


    The problem is for instance if page1 content size is equal 800px height and page2 content size is equal 600px height. Since my viewport height is 600px so page1 requires scrollbar but not page2. What's happening is once I've set "qgwebview->setGeometry(QRectF(view->geometry().topLeft(), s));" on page1, page2 content size returns 800px height, which is at least controversial.

    This approach seems to work if your page height increases gradually, however once a page content size is smaller than the previous then the value returned by contentsSizeChanged(QSize) is not valid.

    I've tried changing the size/geometry of WebPage and WebFrame with no success, which was expected since they are not GGraphicsObjects. Any Suggestions???

    Hopefully I could make my self clear, If don't please let me know.

  2. #2
    Nokia Developer Moderator divanov's Avatar
    Join Date
    Oct 2009
    Posts
    4,326
    Quote Originally Posted by romulovitor View Post
    Using the example available on /opt/qt4-maemo5/examples/maemo5/maemobrowser/
    Did you really give a path to your local files on a web forum?
    http://qt.gitorious.org/+qt-develope...5/maemobrowser

    Quote Originally Posted by romulovitor View Post
    The problem is for instance if page1 content size is equal 800px height and page2 content size is equal 600px height. Since my viewport height is 600px so page1 requires scrollbar but not page2. What's happening is once I've set "qgwebview->setGeometry(QRectF(view->geometry().topLeft(), s));" on page1, page2 content size returns 800px height, which is at least controversial.
    Actually it's very much similar to behaviour of QGraphicsScene::sceneRect
    http://doc.trolltech.com/4.6/qgraphi...sceneRect-prop
    If I understood it correctly Ajax script is just moving things around the page,
    but the contents' size always is the largest existed bounding rectange.
    It would be nice to make a small test app to check my theory.
    Last edited by divanov; 2010-02-28 at 09:06. Reason: trying to make it clear :)

  3. #3
    Registered User romulovitor's Avatar
    Join Date
    Mar 2008
    Posts
    26
    >> Did you really give a path to your local files on a web forum?
    My Bad! I assumed that this was a qt4maemo forum, and everybody has already qt 4.6 examples installed ("fakeroot apt-get install libqt4-maemo5-examples")


    >>It would be nice to make a small test app to check my theory.
    Based on my tests, your theory is pretty accurate.
    Last edited by romulovitor; 2010-03-01 at 19:21. Reason: More tests required

  4. #4
    Nokia Developer Moderator divanov's Avatar
    Join Date
    Oct 2009
    Posts
    4,326
    Quote Originally Posted by romulovitor View Post
    I assumed that this was a qt4maemo forum, and everybody has already qt 4.6 examples installed ("fakeroot apt-get install libqt4-maemo5-examples")
    You also need to enable extras-devel repository and there are plenty people who are still on Qt 4.5.3.

  5. #5
    Registered User romulovitor's Avatar
    Join Date
    Mar 2008
    Posts
    26
    I think I got it. Here's what I did:

    1) On "setWidget(QGraphicsWidget *widget)" function I created connection to contentSizeChange()
    connect(view->page()->mainFrame(), SIGNAL(contentsSizeChanged(QSize)), this, SLOT(myContentsSizeChanged(QSize)));

    2) On "myContentsSizeChanged(QSize)" I check if new content size is different from qgwebview currentSize. If it is then I call
    resizeWebViewToFrame()

    3) On "resizeWebViewToFrame()" replace line where variable size is set
    replace: QSizeF s = view->page()->mainFrame()->contentsSize();
    with: QSizeF s = QSizeF(view->page()->mainFrame()->documentElement().geometry().size());

    4) Compile and celebrate with a weird dance!! ;-)


    Apparently "mainFrame()->contentsSize();" will always return the largest bounding rect of all items on the scene, whereas "mainFrame()->documentElement().geometry().size()" will actually return the document size. Doing this on my previous example, Page 2 return 600px height.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved