Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Qt 检查是否选中列表视图中的复选框_Qt - Fatal编程技术网

Qt 检查是否选中列表视图中的复选框

Qt 检查是否选中列表视图中的复选框,qt,Qt,我创建了一个模型,它在listView中显示可检查字符串的列表。我不知道如何检查listView中显示的字符串是否被选中。有人知道怎么做吗? 编辑: 在我的名为Line_Counter的对话类中,我有一个fnc: void Line_Counter::add_files() { QStringList selected_files = QFileDialog::getOpenFileNames();//here I'm getting those files if (selec

我创建了一个模型,它在listView中显示可检查字符串的列表。我不知道如何检查listView中显示的字符串是否被选中。有人知道怎么做吗?
编辑:

在我的名为Line_Counter的对话类中,我有一个fnc:

void Line_Counter::add_files()
{
    QStringList selected_files = QFileDialog::getOpenFileNames();//here I'm getting those files

    if (selected_files.size())
    {
        model_->setData(QModelIndex(),selected_files);//here I'm adding them to my model
    }

}

连接(指针到窗口项、信号(切换(bool))、指针到窗口、插槽(somefunc(bool))

您好,您是说PointerToyorItem我的模型负责存储和响应listView吗?好的,最简单的方法是为每个字符串创建QCheckListItem,然后将它们添加到listView中(查找文档以了解有关此类的更多信息),然后您将执行类似于connect(复选框1,信号(切换(bool)),型号,插槽(somefunc(bool)),复选框1是指向QCheckListItem的指针,但QCheckListItem存在问题。寻找这个线程,我想这就是你需要的,我还可以在ListWidget中使用模型视图方法吗?我认为有不适合这种方法的,你在想什么?
void Line_Counter::add_files()
{
    QStringList selected_files = QFileDialog::getOpenFileNames();//here I'm getting those files

    if (selected_files.size())
    {
        model_->setData(QModelIndex(),selected_files);//here I'm adding them to my model
    }