QScrollArea - how to enable touch interactions to scroll to next item? - qt

I'm using the Nokia Qt SDK and designed a small banner carousel in the top area. It looks like this:
The hierarchy looks like:
After installing this in the emulator, I try to make it scrollable (flinging). It's a simple task I would guess (like ScrollView in Android, or UIScrollView in iOS), but so far no joy. All links in the internet point me of custom scroll implementations etc etc. which I don't want to do nor expect to do as Qt should be a higher level framework? What is the state of the art here? ;-)
Question in short: How can I make this QScrollArea respond to touch (fling, scroll, drag etc) events and reveal the other widgets in the queue? I'm not expecting it to be able to "snap" into a child widget (which is another requirement later ;)).

Take a look at Flickable (at http://blog.qt.io/blog/2009/07/19/kinetic-scrolling-on-any-widgets/) and FlickCharm (linked to from that first address ) either to have an idea on how to implement it on your own or use it as is.
Note that it might not be necessary if your target is Maemo, as its Qt port handles it.

Have you tried enabling gestures? I haven't used the gesture support yet, but it looks like it's as easy as
scrollEvents->grabGesture(Qt::SwipeGesture);
// or...
scrollEvents->grabGesture(Qt::PanGesture);
I don't know if QScrollArea already handles gestures, so if that doesn't work, you may need to sub-class QScrollArea and override the event method to handle gesture events, as described in the Gestures Programming Guide.

Related

Throughoutly though about some functionality of qt

I'm new to qt, and i have a simble (may be pretty dumb) question that needed to be answer:
As far as i acknowledge, qt could be use to made applications GUI (probaly its most well-knowed purpose), the program i'm trying to code work like this: you enter the program, its show three boxs: enter, setting, exit (like those main menus we see in videos game). when we click enter, it will show the main content, or when we click exit, it quit. i am able to code the layout at which show the content of those choices, but can someone explain to me, does qt support the transitions between layout, like, how to do it, a key work would be suffice
regards
which transitions?
qt have best docs about all things in that(except 1% of it)
QEventTransition Class
Event Transitions Example

Build photo editor interface using Qt

I would like to create an application using Qt (PyQt5 specifically) that has a photo editor like interface. More specifically, I would like it to have:
No main window
Free-floating toolbar
Free-floating context window
Startup dialog
Edit-windows
The idea is to have the toolbar and context window persist for as along as the application is running. The user then opens one or multiple documents (e.g. images in the photo editor example) and uses the options in the toolbar to modify the document(s).
My first question is; does this type of application interface have a specific name, something akin to MDI or SDI? I've been searching for "photo editor interface" and variations on that, but haven't been able to find a search string that seems to hit the mark. For instance, I've tried "build a photo editor type interface with Qt" but it doesn't yield anything useful.
The second question I have is, what is the best way to build a Qt application that doesn't spawn a main window? It seems like I could kludge an assortment of dialogs together to make this happen, but I would really like to use a lot of the functionality of QMainWindow (toolbars, menus, top-level management of the application). Is there a way to launch QMainWindow, display the menu and toolbar, but suppress the main window?
I plan to primarily use this application on OSX, but would also like it to perform well on Windows and Linux.
QMenuBar has explicit support for OSX to have the menu bar behave as expected: http://doc.qt.io/qt-5/qmenubar.html#qmenubar-on-os-x
I think it'll also work on Ubuntu's Unity, which tries to have similar style, but there may be some details you need to take care of. Other desktops should work as expected.
As to how to have individual windows: any Qt widget will be a top level window if it has no parent, so that is an easy way to create windows. If you want to have parent windows (for example to control window stacking order automatically), there's a window flag for that. So you don't need to use QDialog (not sure if you were implying that in your question).
You want to read QWidget documentation carefully to get an idea how all this works.

Need an HTML view for chat window

My Qt project needs a chat window similar to Skype. Namely, the chat history window, not where the user inputs his text. I thought of using some kind of HTML view to programmatically add chat text as it comes in from the chat parties.
Some requirements:
It has to be formatted nicely, support for CSS I can apply to it..
I must have scroll control - e.g. autoscroll to the end of the chat when new chat lines come in, even if I'm currently scrolled up for some reason.
it has to allow a full mouse copy, just like skype.
Will QWebView do the hob? I did not see scroll control API, or being able to "append" new text lines. Will I have to re-create and re-submit the HTML using "setHTML" every time a new line comes through?
Any advice will be appreciated.
You may want to consider using either QTextEdit or QTextBrowser. Both of these widgets have support for HTML (though it may be somewhat limited). These widgets will allow you to append HTML line-by-line. They also inherit from QAbstractScrollArea, which provides you with access to their scroll bars. I'm not sure if they will support CSS, but they do support Qt's style sheets, which might work for you as an alternative if you can't get CSS to work. They also provide out-of-the-box copy, cut, paste, undo and redo (though you'll probably want to customize this for your case).

TV ergonomics in Flex

Im having fun toying with AIR and want to use it to create an application for my TV, but Im coping with a serious & dumb problem : TV ergonomics. Indeed, without a mouse, it is all about focus on elements and moving this focus in a natural fashion.
In HTML this is handled by the browsers perfectly, but in ActionScript Im having a real hard time ! For instance, I don't even know how to have an element on autofocus, so that when I load the app there is already something to click on (without it I just can't interact with my app at all!).
Do you have any idea on the best ways to create a listener for the remote controller arrows and OK button (should be enough) so that I never get stuck in the app ?
So whether you have already struggled with that or if you simply happen to know how to play with the focus and setFocus() parts of Flex, your help is very welcome !
I recommend you look at the Google TV Flash template. It's all about controls and navigation. I'm not sure if this works for Flex as I have not done any gtv development yet.

Qt switching between views

How do I switch between the two screens on the Qt?
For example, I have a button - static text plus a toolbar. Now I will add it to a frame and set it as a central widget. It works well for one window. What if I move it to the next window? Then I need to show some other stuff like another button, some images etc... and what if I come back to the first view again?
How do I show my old widgets back?
I'm not sure I got your problem right but, you could have different scenarios :
You could simply use groupboxes... Some widgets in groupbox1, otherWidget in groupbox2, and you display the groupbox you want to use, hiding the others...
You could use stackedWidget, which simulates "pages" of widgets stacked on top of eachothers... more informations here : http://qt.nokia.com/doc/4.6/qstackedwidget.html.
You could use other way like using tabs : http://doc.trolltech.com/4.6/qtabwidget.html
Maybe this example would be useful to you : http://qt.nokia.com/doc/4.6/dialogs-configdialog.html
Hope it helps a bit !
I'd recommend checking out Animation/States example (should be in /qt/examples/animation/states/ subdirectory of your Qt installation). It shows how to combine state machine representing application logic with presentation layer and get cool animation effects for free (of course if you don't need eye candy, you can set widgets properties without any animation).

Resources