List Widget API

For list controls and list item controls, the model manager provides two object types, List and ListItem. Since the list view is a composite structure, CukeTest provides many methods, which can be understood by combining the table view Table and the tree view Tree.

Corresponding walkthroughs are also provided for the list controls-Walkthrough: Operating List in Qt Applications, which can greatly deepen the understanding of the API.

ListView Widget

Type Definition

JavaScript
Python
export interface IQList extends IQtControl {
    getItem(rowIndex: number): IQListItem;
    select(index: number): Promise<void>;
    selectedIndex(): Promise<number>;
    findItem(text: string): Promise<IQListItem | null>;

    data(): Promise<string[]>;
    itemCount(): Promise<number>;
    scrollToTop(): Promise<void>;
    scrollTo(index: number): Promise<void>;
    scrollToBottom(): Promise<void>;
}
class QList(QItemView):
	def data() -> List[str]
	def getItem(nameOrIndex: Union[str, int]) -> "QListItem"
	def select(nameOrIndex: Union[str, int]) -> "QListItem"
	def selectedIndex() -> int
	def findItem(text: str, options: Optional[FindItemOptional]=None) -> "QListItem"
	def itemCount() -> int
	def scrollToTop() -> None
	def scrollTo(index: int) -> "QListItem"
	def scrollToBottom() -> None

API

The following is the API for the List control.

getItem(rowIndex): IQListItem

Get the automation object corresponding to the list item at the specified index position.

  • rowIndex: number type, which represents the number of the list item in the list. If it is the first item, it is 0.
  • Return value: IQListItem object, which is the automation object of the ListItem control. Note that this is a synchronous method and does not require the await keyword, nor will it match the controls in the application. Matches are only performed when an asynchronous method on the object is executed.

findItem(text: string): Promise<IQListItem | null>

Search for the target list item by name, return the automation object of the target list item, or return null if it is not found.

  • text: string type, the content or text of the desired target list item;
  • Return value: Promise<IQListItem> or Promise<null> type, asynchronously search the target list item in the application, and return null if it is not found.

select(index): Promise<void>

Select the list item at the specified index position.

  • index: number type, which represents the number of the list item in the list. If it is the first item, it is 0.
  • Return value: Asynchronous method that does not return any value.

scrollToTop(): Promise<void>

Scroll to the top of the list.

  • Return value: Asynchronous method that does not return any value.

scrollTo(index): Promise<void>

Scroll to the target index position. If the target location has not been loaded, it will be loaded until the target index location is loaded.

  • index: number type, which represents the number of the list item in the list. If it is the first item, it is 0.
  • Return value: Asynchronous method that does not return any value.

scrollToBottom(): Promise<void>

Scroll to the bottom of the list. The bottom of the list here refers to the bottom of the loaded list, to avoid performance problems caused by very long lists.

  • Return value: Asynchronous method that does not return any value.

data(): Promise<string[]>

Get the data in the list view and return. If the list view adopts batch loading (or can be understood as lazy loading), only the loaded data will be obtained, and the unloaded data cannot be obtained.

  • Return value: Promise<string[]> type, a string array composed of list option values. You need to use the await keyword to retrieve the results.

rowCount(): Promise<number>

Get the number of options in the list view. If the list view adopts batch loading (or can be understood as lazy loading), only the loaded data will be calculated, and the unloaded data will not be counted.

  • Return value: Promise<number> type, indicating the number of options in the current list. You need to use the await keyword to retrieve the results.

selectedIndex(): Promise<number>

Get the index position of the selected option in the list view.

  • Return value: Promise<number> type, indicating the index position of the selected option. You need to use the await keyword to retrieve the results.

List item control: ListItem

For the list item controls in the list, the model manager provides the ListItem type. Unlike the methods provided by the List object to manipulate list items (such as scrollTo(), select(), the list item control itself contains position information, so its methods do not require additional parameters .

Type Definition

JavaScript
Python
export interface IQListItem extends IQtControl {
    value(): Promise<string>;
    select(): Promise<void>;
    scrollIntoView(): Promise<void>;
}
class QListItem(QItemViewItem):
	def value() -> str
	def select() -> None
	def scrollIntoView() -> None
	def itemIndex() -> int
	def checkState() -> bool
	def toggleCheck(checkState: bool) -> None

API

value(): Promise<string>

Get the content of the list item.

  • Return value: Promise<string> type, the content of the list item. You need to use the await keyword to retrieve the results.

select(): Promise<void>

Select the list item. If the item is not in the visible range, it will automatically scroll to the location of the item.

  • Return value: Asynchronous method that does not return any value.

editable(): Promise<boolean>

If or not the list item can be edited, editable is true, not editable is false.

  • Return value: boolean type, if or not editable.

selected(): Promise<boolean>

The selected status of the list item, true for selected, false for unselected (collapsed).

  • Return value: boolean type, if or not it is checked.

scrollIntoView(): Promise<void>

Scroll to the position of the list item.

  • Return value: Asynchronous method that does not return any value.

Chinese version click here.

results matching ""

    No results matching ""