이 페이지에서

PlaceSearchSuggestionModel QML Type

검색어 추천 기능을 제공합니다. 더 보기...

Import Statement: import QtLocation 6.12
Since: QtLocation 5.5

속성

방법

상세 설명

PlaceSearchSuggestionModel은 사용자가 검색어를 입력할 때 검색어 제안을 제공하는 데 사용할 수 있습니다. 검색 제안 결과가 관련성이 있도록 하려면, 이 모델의 속성은 실제 검색 쿼리를 수행하는 데 사용될 PlaceSearchModel 의 속성과 일치해야 합니다.

이 모델이 제공하는 데이터에 접근하는 방법에는 ‘ suggestions ’ 속성을 이용하는 방법과 뷰 및 델리게이트를 이용하는 방법, 두 가지가 있습니다. 후자가 권장되는 방법입니다.

offset 및 limit 속성을 사용하여 페이지 단위로 제안 결과를 가져올 수 있습니다. offset 및 limit 속성이 설정되면 offset 과 (offset + limit - 1) 사이의 제안 결과가 반환됩니다. 페이지 분할 지원 여부는 플러그인마다 다를 수 있습니다.

이 모델은 다음 역할에 대한 데이터를 반환합니다:

역할유형설명
suggestion문자열제안된 검색어.

다음 예제는 PlaceSearchSuggestionModel을 사용하여 부분 검색어로부터 추천 검색어를 가져오는 방법을 보여줍니다. searchArea 은 PlaceSearchModel 을 사용하여 실제 장소 검색을 수행하는 데 사용될 조건과 일치하도록 설정되어 있습니다.

import QtQuick
import QtPositioning
import QtLocation

PlaceSearchSuggestionModel {
    id: suggestionModel

    plugin: myPlugin

    // Brisbane
    searchArea: QtPositioning.circle(QtPositioning.coordinate(-27.46778, 153.02778))

    onSearchTermChanged: update()
}

ListView {
    model: suggestionModel
    delegate: Text { text: suggestion }
}

PlaceSearchModel 및 QPlaceManager도 참조하십시오 .

속성 문서

limit : int

이 속성은 반환될 항목 수의 상한을 지정합니다.

offset도 참조하십시오 .

offset : int

이 속성은 모델의 첫 번째 항목의 인덱스를 저장합니다.

limit도 참조하십시오 .

plugin : Plugin

이 속성에는 검색을 수행하는 데 사용될 제공자 Plugin 가 포함되어 있습니다.

searchArea : geoShape

이 속성은 검색 영역을 지정합니다. 모델에서 반환하는 검색 제안 결과는 지정된 검색 영역과 관련이 있습니다.

이 속성이 ` geoCircle `로 설정된 경우, ` radius ` 속성은 설정하지 않아도 되며, 이 경우 ` Plugin `가 검색에 적합한 반경을 자동으로 선택합니다.

searchTerm : string

이 속성은 쿼리에 사용된 부분 검색어를 저장합니다.

status : enum [read-only]

이 속성은 모델의 상태를 나타냅니다. 다음 중 하나일 수 있습니다:

PlaceSearchSuggestionModel.Null검색 쿼리가 실행된 적이 없습니다. 모델이 비어 있습니다.
PlaceSearchSuggestionModel.Ready검색 쿼리가 완료되었으며, 결과를 확인할 수 있습니다.
PlaceSearchSuggestionModel.Loading현재 검색 쿼리가 실행 중입니다.
PlaceSearchSuggestionModel.오류이전 검색 쿼리를 실행하는 동안 오류가 발생했습니다.

suggestions : stringlist [read-only]

이 속성은 모델이 현재 보유하고 있는 예측 검색어 목록을 담고 있습니다.

메서드 문서

void cancel()

진행 중인 검색 제안 작업을 즉시 취소하고 모델 상태를 ` PlaceSearchSuggestionModel.Ready`로 설정합니다. 모델은 작업이 시작되기 전의 검색 제안 내용을 그대로 유지합니다.

작업이 진행 중이 아닌 경우, cancel()을 호출해도 아무런 효과가 없습니다.

update() 및 status도 참조하십시오 .

string errorString()

이 읽기 전용 속성은 가장 최근의 검색 제안 모델 오류에 대한 텍스트 형식의 설명을 포함합니다. 오류가 발생하지 않았거나 모델이 초기화된 경우, 빈 문자열이 반환됩니다.

텍스트로 표현할 수 없는 오류가 발생한 경우에도 빈 문자열이 반환될 수 있습니다.

void reset()

모델을 초기화합니다. 모든 검색 제안이 지워지고, 처리 중인 요청은 모두 취소되며, 발생할 수 있는 오류가 모두 제거됩니다. 모델 상태는 ` PlaceSearchSuggestionModel.Null`로 설정됩니다.

void update()

제공된 쿼리 매개변수를 기반으로 모델을 업데이트합니다. 모델에는 부분 문자열 searchTerm 및 searchArea 에 대한 검색 제안 목록이 채워집니다. plugin 에서 지원하는 경우, limit 및 offset 와 같은 다른 매개변수도 지정할 수 있습니다. update() 는 처리할 매개변수 집합을 plugin 에 전송합니다.

모델이 업데이트되는 동안 모델의 status 는 PlaceSearchSuggestionModel.Loading 로 설정됩니다. 모델이 성공적으로 업데이트되면 status 는 PlaceSearchSuggestionModel.Ready 로 설정되고, 업데이트에 실패하면 status 는 PlaceSearchSuggestionModel.Error 로 설정되며 모델이 지워집니다.

이 예제는 모델의 사용법을 보여줍니다.

PlaceSeachSuggestionModel {
    id: model
    plugin: backendPlugin
    searchArea: QtPositioning.circle(QtPositioning.coordinate(10, 10))
    ...
}

MouseArea {
    ...
    onClicked: {
        model.searchTerm = "piz"
        model.searchArea.center.latitude = -27.5;
        model.searchArea.cetner.longitude = 153;
        model.update();
    }
}

더 자세한 예제는 Places (QML) 예제에서 확인할 수 있습니다.

cancel() 및 status도 참조하십시오 .

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.