zoukankan      html  css  js  c++  java
  • Qt ListView控件使用心得

    1 使用前必须初始化(即使用预定义模型),这里利用QStringListModel进行初始化,Qt还支持其他不同Model对listview进行初始化。

    1     QString str;
    2     QStringListModel *model;
    3     QStringList current_cloud_id_list;
    4     current_cloud_id_list.push_back(str);
    5     model = new QStringListModel(this);
    6     model->setStringList(current_cloud_id_list);
    7     dialog_removePCD_ui->listView_CurrentID->setModel(model);

    2 ListView初始化后,才可以获取其rowCount:

    int row_num = dialog_removePCD_ui->listView_RemovedID->model()->rowCount();

    3 获取某一行某一列的文本数据:

    1     // row_idx为该行索引序号, column_idx为该列索引序号,两者都以0开始
    2     QString str = dialog_removePCD_ui->listView_RemovedID->model()->index(row_idx, column_idx).data().toString();
  • 相关阅读:
    敏感信息脱敏实现
    SpringBoot集成Swagger2
    CSS三大特性
    background
    background-attachment
    background-position
    background-repeat
    background-image
    background-color
    CSS元素显示模式
  • 原文地址:https://www.cnblogs.com/ybqjymy/p/15423213.html
Copyright © 2011-2022 走看看