|
2010-11-15
, 01:46
|
Posts: 1,048 |
Thanked: 979 times |
Joined on Mar 2008
@ SF Bay Area
|
#2
|
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.
The Following User Says Thank You to uvatbc For This Useful Post: | ||
|
2010-11-16
, 20:28
|
|
Posts: 319 |
Thanked: 221 times |
Joined on Jan 2010
@ Finland
|
#3
|
|
2010-11-16
, 20:47
|
|
Posts: 319 |
Thanked: 221 times |
Joined on Jan 2010
@ Finland
|
#5
|
|
2010-11-16
, 23:00
|
|
Posts: 2,448 |
Thanked: 9,523 times |
Joined on Aug 2010
@ Wigan, UK
|
#6
|
There is builtin-functionality in Qt: QSearchFilterProxyModel is all you need.
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)
|
2010-11-21
, 21:59
|
Posts: 2 |
Thanked: 2 times |
Joined on Nov 2010
|
#7
|
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.
Last edited by slvr32; 2010-11-14 at 22:46.