![]() |
Здравствуйте, гость ( Вход | Регистрация )
![]() |
kibsoft |
![]()
Сообщение
#1
|
Участник ![]() ![]() Группа: Участник Сообщений: 180 Регистрация: 21.7.2009 Из: Самара Пользователь №: 928 Спасибо сказали: 14 раз(а) Репутация: ![]() ![]() ![]() |
Как искать например строку в модели? Перебирать строки? setFilter()?
|
|
|
![]() |
MoPDoBoPoT |
![]()
Сообщение
#2
|
Участник ![]() ![]() Группа: Участник Сообщений: 172 Регистрация: 7.5.2009 Из: Москва Пользователь №: 738 Спасибо сказали: 44 раз(а) Репутация: ![]() ![]() ![]() |
Именно в QSqlTableModel? Ведь работа с QSqlTableModel подразумевает работу с БД, у которой как раз одно из предназначений - поиск данных.
Если именно в QSqlTableModel, то есть: Цитата(QtAssistant) QModelIndexList QAbstractItemModel::match ( const QModelIndex & start, int role, const QVariant & value, int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags( Qt::MatchStartsWith | Qt::MatchWrap ) ) const [virtual]
Returns a list of indexes for the items in the column of the start index where the data stored under the given role matches the specified value. The way the search is performed is defined by the flags given. The list that is returned may be empty. The search starts from the start index, and continues until the number of matching data items equals hits, the search reaches the last row, or the search reaches start again, depending on whether MatchWrap is specified in flags. If you want to search for all matching items, use hits = -1. By default, this function will perform a wrapping, string-based comparison on all items, searching for items that begin with the search term specified by value. Note: The default implementation of this function only searches columns, This function can be reimplemented to include other search behavior. |
|
|
kibsoft |
![]()
Сообщение
#3
|
Участник ![]() ![]() Группа: Участник Сообщений: 180 Регистрация: 21.7.2009 Из: Самара Пользователь №: 928 Спасибо сказали: 14 раз(а) Репутация: ![]() ![]() ![]() |
Ну если я например уже заполнил модель всей таблицей, зачем мне делать поиск средствами СУБД(работать дольше будет), если все это есть в оперативке? Или я что-то не так понимаю?
|
|
|
![]() ![]() ![]() |
![]() |
|
Текстовая версия | Сейчас: 10.6.2025, 17:18 |