Interactive content fixed in/on view while it scrolls over scene?



  • Hi,

    If I want to make maximum use of the screen on a mobile device then I'd like to put some buttons around the edge of my scrolling game such that they don't take out the entire width or height of the lines they're on. I assume I can put non-interactive content like the score in place by implementing QGraphicsView::drawForeground() but what about buttons I can click?

    I'm guessing that putting them in the scene and moving them at the same time as the view is going to be bad for performance (and a fairly crazy looking design). Maybe a standard QWidget (z-ordered above the QGraphicsView with raise() and a transparent background)?

    Any suggestions on the best approach?

    Thanks,
    Mark



  • [quote author="m_p_wilcox" date="1291394410"]I want to make maximum use of the screen on a mobile device[/quote]
    [quote author="m_p_wilcox" date="1291394410"]I'd like to put some buttons around the edge of my scrolling game[/quote]
    [quote author="m_p_wilcox" date="1291394410"]what about buttons I can click?[/quote]
    [quote author="m_p_wilcox" date="1291394410"]putting them in the scene and moving them at the same time as the view is going to be bad for performance (and a fairly crazy looking design)[/quote]

    I know you're looking at Qt C++ GUI approach, but all these issues are much easier to tackle and solved quicker by using..
    [quote author="m_p_wilcox" date="1291394410"]Any suggestions on the best approach?[/quote]
    QtQuick? Don't shoot me!

    You can still use normal Qt C++ for all the game logic and the main screen. QtQuick is just used for the UI and layout.



  • Thanks - I originally looked at doing this in QML - I don't see how it helps at all with this particular issue. Indeed the trolls that responded to my original questions suggested that QML was not yet really suited to the type of game I'm trying to write.

    Frankly if this has any chance of running well on an S60 5th Edition device I'm going to have to do everything native! (Well, maybe the intro screens could be in QML but I'd rather not make N8 users upgrade for something so trivial to do anway).



  • Oh, well that is the only drawback really. QML isn't available yet without including a 13MB package for N8 users. And isn't allowed on Ovi Store for anyone yet.

    However, I'm not suggesting to use QML for the whole game. Only a few lines to do the buttons/animations of the UI like you described in your post. Would make life much easier.
    The actual game can all be done inside an item in the centre, controlled entirely from the QML Wrapper (in native Qt C++).

    You can just do this in Qt C++ instead if you want (just use Objects over the top of your main scene). Especially if you need to release soon.



  • I want the buttons to overlap the rectangle of QGraphicsView that's running the game.

    bq. You can just do this in Qt C++ instead if you want (just use Objects over the top of your main scene). Especially if you need to release soon.

    When you say Objects do you mean QGraphicsObjects? How do I put them over the top of my main scene (which will be scrolling past in the view at a significant speed!) - that's really what I'm asking?



  • [quote author="m_p_wilcox" date="1291394410"]Maybe a standard QWidget (z-ordered above the QGraphicsView with raise() and a transparent background)?[/quote]

    I think "Yes", it is a possible solution.

    If you need nothing more complex than click-able button then QGraphicsView::drawForeground() also works with special mouse handling.

    Definitely do not move them on scene.

    I am not sure but maybe it will be better to create your own widget class and re-implement paint() instead of using scene.



  • Another option would be to add items to the scene with the QGraphicsItem::ItemIgnoresTransformations flag set and a z-value set to maximum.



  • [quote author="Bradley" date="1291429529"]Another option would be to add items to the scene with the QGraphicsItem::ItemIgnoresTransformations flag set and a z-value set to maximum.[/quote]

    Maybe, I do not understand the idea, but Qt doc states something different:

    This flag is useful for keeping text label items horizontal and unscaled, so they will still be readable if the view is transformed. When set, the item's view geometry and scene geometry will be maintained separately.

    So, it will be moved with scene, but not rotated.



  • Yes, if view is moved around the scene, the items positions must also be updated to hold them in a constant location in the view.



  • [quote author="Bradley" date="1291441829"]Yes, if view is moved around the scene, the items positions must also be updated to hold them in a constant location in the view.[/quote]

    I think it may be a performance problem. But only prototype may show does performance problem really exist.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.