当前位置: 首页 > news >正文

asp网站后台无法编辑百度关键词优化软件网站

asp网站后台无法编辑,百度关键词优化软件网站,福步外贸官网,蛋糕店网页设计素材文章目录 Qt QtableWidget表格删除选中行只能选择一行,点击按钮后,删除一行可以选择中多行,点击按钮后,删除多行选中某一列中的不同行,点击按钮后,删除多行 QTableWidgetSelectionRange介绍QTableWidget的选…

文章目录

  • Qt QtableWidget表格删除选中行
    • 只能选择一行,点击按钮后,删除一行
    • 可以选择中多行,点击按钮后,删除多行
    • 选中某一列中的不同行,点击按钮后,删除多行
  • QTableWidgetSelectionRange介绍
  • QTableWidget的选择模式

Qt QtableWidget表格删除选中行

只能选择一行,点击按钮后,删除一行

设置

	QTableWidget *tb = ui->tableWidget;tb->setSelectionBehavior(QAbstractItemView::SelectRows);tb->setSelectionMode(QAbstractItemView::SingleSelection);

操作

    QTableWidget *tb = ui->tableWidget;int curRow=tb->currentRow();     //当前行号tb->removeRow(curRow);           //删除当前行及其items

可以选择中多行,点击按钮后,删除多行

设置

    QTableWidget *tb = ui->tableWidget;tb->setSelectionBehavior(QAbstractItemView::SelectRows);tb->setSelectionMode(QAbstractItemView::ExtendedSelection);

操作

	QTableWidget *tb = ui->tableWidget;QItemSelectionModel  *m_selection = tb->selectionModel();QModelIndexList indexList = m_selection->selectedIndexes();QList<int> list;int prev =-1,curr=-1;if(indexList.length()>1){//预处理第一行prev  = indexList.at(0).row();list.append(prev);for(int i=1;i<indexList.length();i++){//qDebug() <<"row: "<< indexList.at(i).row() <<"column: "<<indexList.at(i).column();curr = indexList.at(i).row();if(prev ==curr){continue;}else{prev = curr;list.append(prev);}}}else if(indexList.length()==1){list.append(indexList.at(0).row());}else{return;}//从大到小排序,必须从最后一行  往前删除  不然会打乱顺序std::sort(list.rbegin(),list.rend());//根据填充到的数据 删除选中列for(int j = 0; j <list.size(); j++){int cc = list.at(j);tb->removeRow(cc);           //删除当前行及其items}

选中某一列中的不同行,点击按钮后,删除多行

无需设置setSelectionBehavior(QAbstractItemView::SelectRows),但是可以选择的那一列最好设置为不可编辑。按下Ctrl键,选择多行。

设置1

    tableView->setSelectionMode(QAbstractItemView::ExtendedSelection);//选择模式m_selection = new QItemSelectionModel(m_model,this);           //创建选择模型tableView->setSelectionModel(m_selection); //设置选择模型

设置2

        QStandardItem *item1 = new QStandardItem("aa1");item1->setEditable(false);QStandardItem *item2 = new QStandardItem("aa2");item2->setEditable(false);        QList<QStandardItem *> list = {item1,item2};model->appendRow(list);        

操作

            QModelIndexList indexList = m_selection->selectedIndexes();QList<int> list;int sameColumn=-1;for(int i=0;i<indexList.length();i++){if(i==0){sameColumn=indexList.at(i).column();}//qDebug() <<"row: "<< indexList.at(i).row() <<"column: "<<indexList.at(i).column();if(sameColumn!=indexList.at(i).column()){//上面currentColumnChanged信号其实已经让用户只能选择同一列,这里双重保险qDebug()<<"你的选择有不同列,请务必选择同一列的不同行来进行多行删除操作";return;}list.append(indexList.at(i).row());}//从大到小排序,必须从最后一行  往前删除  不然会打乱顺序std::sort(list.rbegin(),list.rend());//根据填充到的数据 删除选中列for(int j = 0; j <list.size(); j++){int cc = list.at(j);m_model->removeRow(cc);}

QTableWidgetSelectionRange介绍

QTableWidgetSelectionRange是Qt框架中用于表示QTableWidget中选定的一块单元格区域的类。以下是如何使用QTableWidgetSelectionRange的一些常见操作:

  1. 获取当前选定的单元格区域:
QList<QTableWidgetSelectionRange> ranges = tableWidget->selectedRanges();
  1. 获取第一个选定的单元格区域的起始行、起始列、行数和列数:
if (!ranges.isEmpty()) {int startRow = ranges.first().topRow();int startColumn = ranges.first().leftColumn();int rowCount = ranges.first().rowCount();int columnCount = ranges.first().columnCount();
}
  1. 遍历所有选定的单元格区域:
foreach (const QTableWidgetSelectionRange &range, ranges) {int startRow = range.topRow();int startColumn = range.leftColumn();int rowCount = range.rowCount();int columnCount = range.columnCount();// 进行处理...
}
  1. 检查特定的单元格区域是否被选定:
QTableWidgetSelectionRange range(1, 1, 3, 3); // 定义一个起始行为1,起始列为1,行数和列数为3的区域
if (tableWidget->selectedRanges().contains(range)) {// 区域被选定
}
  1. 清除所有选定的单元格区域:
tableWidget->clearSelection();

QTableWidgetSelectionRange类提供了一种方便的方式来处理QTableWidget中的选择区域。使用它可以获取和操作选定的单元格区域,进行相关的处理和操作。

QTableWidget的选择模式

QTableWidget通过setSelectionMode()SelectionBehavior来设置选择模式

enum QAbstractItemView::SelectionBehavior

ConstantValueDescription
QAbstractItemView::SelectItems0Selecting single items.
QAbstractItemView::SelectRows1Selecting only rows.
QAbstractItemView::SelectColumns2Selecting only columns.

enum QAbstractItemView::SelectionMode

此枚举指示视图如何响应用户选择:

ConstantValueDescription
QAbstractItemView::SingleSelection1When the user selects an item, any already-selected item becomes unselected. It is possible for the user to deselect the selected item by pressing the Ctrl key when clicking the selected item.
QAbstractItemView::ContiguousSelection4When the user selects an item in the usual way, the selection is cleared and the new item selected. However, if the user presses the Shift key while clicking on an item, all items between the current item and the clicked item are selected or unselected, depending on the state of the clicked item.
QAbstractItemView::ExtendedSelection3When the user selects an item in the usual way, the selection is cleared and the new item selected. However, if the user presses the Ctrl key when clicking on an item, the clicked item gets toggled and all other items are left untouched. If the user presses the Shift key while clicking on an item, all items between the current item and the clicked item are selected or unselected, depending on the state of the clicked item. Multiple items can be selected by dragging the mouse over them.
QAbstractItemView::MultiSelection2When the user selects an item in the usual way, the selection status of that item is toggled and the other items are left alone. Multiple items can be toggled by dragging the mouse over them.
QAbstractItemView::NoSelection0Items cannot be selected.
http://www.zhongyajixie.com/news/11536.html

相关文章:

  • 湖南医院响应式网站建设企业seo值怎么提高
  • 微信网站开发详解贵阳网站建设制作
  • 做投资理财网站武汉seo排名
  • 做网站没有高清图片怎么办友情链接平台站长资源
  • 建设执业资格注册管理中心网站百度推广可以自己开户吗
  • 网站域名代办合肥百度搜索排名优化
  • 医院网站备案前置审批如何做网站网页
  • 兽装定制网站网站建设流程是什么
  • 嘉兴网站搜索排名如何进行搜索引擎的优化
  • 网站建设静态代码seo是如何做优化的
  • 怎么做交友网站杭州网站推广大全
  • 湖南网站制作电话谷歌关键词
  • 福建微网站建设价格百度竞价关键词优化
  • 宝鸡做网站线上支付功能网页设计可以自学吗
  • 学校门户网站360推广客服电话是多少
  • 用discuz做交友网站网站制作开发
  • 农产品如何建设网站北京seo优化服务
  • 余姚住房和建设局网站域名大全查询
  • 网站开发w亿玛酷1专注竞价推广遇到恶意点击怎么办
  • 百度电商广告代运营郑州seo教程
  • pc网站做app京东如何制作网站赚钱
  • 出口网站有哪些临沧seo
  • 做网站运营话术百度权重怎么查询
  • 湖南网站搜索排名优化公司营销型网站的公司
  • 做公司网站需要多久百度商家
  • 学网页设计需要什么学历seo优化与品牌官网定制
  • 中国的网站为什么要备案长尾关键词是什么
  • 巩义做网站优化营销页面设计
  • 中文域名网站标识市场调研的方法有哪些
  • 网站开发要会英语吗重庆seo博客