Active Topics

 


Reply
Thread Tools
slvr32's Avatar
Posts: 168 | Thanked: 104 times | Joined on Feb 2008 @ California, USA
#1
Is there any built-in Qt/C++ API for Maemo to implement the handy 'find as you type' functionality in apps, like we see in the Application Manager, or at the home screen, when typing starts a search in the Contacts app?

And if there doesn't happen to be a convenient API, how might someone implement equivalent functionality?

I did a couple of quick google search and ran across QKeyEvent and QWidget::keyPressEvent, but I figured it was worth asking about a Qt/Maemo solution here.

I'm just getting started on Qt/C++ programming, but I do have some C++ background, and picked up the 'C++ GUI Programming with Qt 4' and 'Advanced Qt Programming' books for references.

So far, I've written a very minimal skeleton of a Netflix queue manager app, using a QStackedWidget, and QComboBox to switch between various dialogs (just getting my feet wet with Qt/C++), but I'd like to implement 'find as you type' functionality, instead of something like a Find: <textbox> in most places.

Edit: I think I got it working (at least I'm catching the keyPressEvent), and I'll verify on the n900 later.

I guess the important part was realizing that I needed to care about keyPressEvent in the parent widget, and then decide what to do with the appropriate child widgets.

I'm still curious if the 'find as you type' box that pops up on the bottom of the screen on the n900 is a particular (standard?) control.
Attached Images
 

Last edited by slvr32; 2010-11-14 at 22:46.
 
Posts: 1,048 | Thanked: 979 times | Joined on Mar 2008 @ SF Bay Area
#2
Originally Posted by slvr32 View Post
Is there any built-in Qt/C++ API for Maemo to implement the handy 'find as you type' functionality in apps, like we see in the Application Manager, or at the home screen, when typing starts a search in the Contacts app?

And if there doesn't happen to be a convenient API, how might someone implement equivalent functionality?

I did a couple of quick google search and ran across QKeyEvent and QWidget::keyPressEvent, but I figured it was worth asking about a Qt/Maemo solution here.

I'm just getting started on Qt/C++ programming, but I do have some C++ background, and picked up the 'C++ GUI Programming with Qt 4' and 'Advanced Qt Programming' books for references.

So far, I've written a very minimal skeleton of a Netflix queue manager app, using a QStackedWidget, and QComboBox to switch between various dialogs (just getting my feet wet with Qt/C++), but I'd like to implement 'find as you type' functionality, instead of something like a Find: <textbox> in most places.

Edit: I think I got it working (at least I'm catching the keyPressEvent), and I'll verify on the n900 later.

I guess the important part was realizing that I needed to care about keyPressEvent in the parent widget, and then decide what to do with the appropriate child widgets.

I'm still curious if the 'find as you type' box that pops up on the bottom of the screen on the n900 is a particular (standard?) control.
If you use a QListView then there is an "automatic" keyboard based search but it is very transient and doesn't provide any visual feedback like the one in your screenshots. The widgets in your screenshot needs to be done on your own, there is no standard.
__________________
qgvdial: Google Voice client. All downloads
qgvtp: Phone integration for the n900 that dials out and sends texts using qgvdial.
mosquitto: message broker that implements the MQ Telemetry Transport protocol version 3.
qgvnotify: Google voice and contacts notifier for diablo and maemo.

If you want to thank me, click the Thanks button.
If you'd like to thank my applications, vote to move them to extras.
 

The Following User Says Thank You to uvatbc For This Useful Post:
rooster13's Avatar
Posts: 319 | Thanked: 221 times | Joined on Jan 2010 @ Finland
#3
Damn! I was hoping there was a live search in Qt. I would really like to implement that in my app Shortcut Stash
 
Posts: 2 | Thanked: 2 times | Joined on Nov 2010
#4
There is builtin-functionality in Qt: QSearchFilterProxyModel is all you need.
 

The Following 2 Users Say Thank You to axeljaeger For This Useful Post:
rooster13's Avatar
Posts: 319 | Thanked: 221 times | Joined on Jan 2010 @ Finland
#5
Cheers mate! I will check that out.
 
marxian's Avatar
Posts: 2,448 | Thanked: 9,523 times | Joined on Aug 2010 @ Wigan, UK
#6
Originally Posted by axeljaeger View Post
There is builtin-functionality in Qt: QSearchFilterProxyModel is all you need.
Would that work on a list item that had more than one text widget (for example two QLabels containing artist name and song title)? I added a QLineEdit to a toolbar and coded the filter as follows (in Python):

Code:
self.listWidget.keyPressEvent = self.filterList

def filterList(self, event):
        """
        Shows the toolbar containing a lineEdit 
        and filters the listWidgetItems according 
        to the string entered by the user.
        """
        if event.key() not in (Qt.Key_Left, Qt.Key_Right, Qt.Key_Up, Qt.Key_Down, Qt.Key_Backspace, Qt.Key_Return, Qt.Key_Control):
            self.toolBar.setVisible(True)
            self.lineFilter.insert(event.text())
        if event.key() == Qt.Key_Backspace:
            self.lineFilter.backspace()
        for row in range(self.listWidget.count()):
            item = self.listWidget.item(row)
            itemWidget = self.listWidget.itemWidget(item)
            title = itemWidget.titleLabel.text()
            author = itemWidget.authorLabel.text()
            if not title.contains(self.lineFilter.text(), Qt.CaseInsensitive) and not author.contains(self.lineFilter.text(), Qt.CaseInsensitive):
                self.listWidget.setRowHidden(row, True)
            else:
                self.listWidget.setRowHidden(row, False)
            if self.lineFilter.text() == "":
                self.toolBar.setVisible(False)
__________________
'Men of high position are allowed, by a special act of grace, to accomodate their reasoning to the answer they need. Logic is only required in those of lesser rank.' - J K Galbraith

My website

GitHub

Last edited by marxian; 2010-11-16 at 23:07.
 
Posts: 2 | Thanked: 2 times | Joined on Nov 2010
#7
It doesnt work on item based widgets. It is supposed to work together with an architecture where model and view are two seperate classes. See my article on this: http://wiki.forum.nokia.com/index.ph...Search_with_Qt

No matter whether you plan to use QSearchFilterProxy or not, I recommend to write an own model class and not use the so called "convinience" classes. If might look simpler first, but if you think about it, you will notice that you have one copy of all your data in every view and that will be a hassle to sync with your main data structure when anything changes.

For your usecase, I suggest to use a model and a QML-based view. With QML, you have the freedom to design the data view to have additional elements such as labels per row everywhere you want.
 
Reply


 
Forum Jump


All times are GMT. The time now is 22:43.