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

做图表的网站 免费专业的官网设计公司

做图表的网站 免费,专业的官网设计公司,最佳线上网站制作模板,江苏省住房和建设部网站文章目录 Qt QtableWidget表格删除选中行只能选择一行#xff0c;点击按钮后#xff0c;删除一行可以选择中多行#xff0c;点击按钮后#xff0c;删除多行选中某一列中的不同行#xff0c;点击按钮后#xff0c;删除多行 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 curRowtb-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();QListint list;int prev -1,curr-1;if(indexList.length()1){//预处理第一行prev indexList.at(0).row();list.append(prev);for(int i1;iindexList.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); QListQStandardItem * list {item1,item2};model-appendRow(list); 操作 QModelIndexList indexList m_selection-selectedIndexes();QListint list;int sameColumn-1;for(int i0;iindexList.length();i){if(i0){sameColumnindexList.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的一些常见操作 获取当前选定的单元格区域 QListQTableWidgetSelectionRange ranges tableWidget-selectedRanges();获取第一个选定的单元格区域的起始行、起始列、行数和列数 if (!ranges.isEmpty()) {int startRow ranges.first().topRow();int startColumn ranges.first().leftColumn();int rowCount ranges.first().rowCount();int columnCount ranges.first().columnCount(); }遍历所有选定的单元格区域 foreach (const QTableWidgetSelectionRange range, ranges) {int startRow range.topRow();int startColumn range.leftColumn();int rowCount range.rowCount();int columnCount range.columnCount();// 进行处理... }检查特定的单元格区域是否被选定 QTableWidgetSelectionRange range(1, 1, 3, 3); // 定义一个起始行为1起始列为1行数和列数为3的区域 if (tableWidget-selectedRanges().contains(range)) {// 区域被选定 }清除所有选定的单元格区域 tableWidget-clearSelection();QTableWidgetSelectionRange类提供了一种方便的方式来处理QTableWidget中的选择区域。使用它可以获取和操作选定的单元格区域进行相关的处理和操作。 QTableWidget的选择模式 QTableWidget通过setSelectionMode()和SelectionBehavior来设置选择模式 enum QAbstractItemView::SelectionBehavior ConstantValueDescriptionQAbstractItemView::SelectItems0Selecting single items.QAbstractItemView::SelectRows1Selecting only rows.QAbstractItemView::SelectColumns2Selecting only columns. enum QAbstractItemView::SelectionMode 此枚举指示视图如何响应用户选择 ConstantValueDescriptionQAbstractItemView::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://wiki.neutronadmin.com/news/85725/

相关文章:

  • 触屏版网站模板张家界网站建设公司
  • 网站空间商排行榜成都装修设计公司首选
  • 网站设计公司 无锡海口自助建站系统
  • 淘宝关键词排名查询网站市场营销策略方案
  • 建设招标网 手机官方网站wordpress分类图标列表
  • 网站结构和布局区别游戏网站开发过程
  • 新手做网站视频大理微网站建设
  • 成都建立网站的公司浙江综合网站建设配件
  • 项目建设备案网站在百度上怎么发布广告
  • 网站建设必备条件wordpress怎么做
  • 公司官网用什么建站程序新中式装修效果图
  • 岳阳手机网站建设商场设计理念
  • wordpress网站邀请码宁波网站推广找哪家
  • 网站开发进度计划是什么做网站便宜还是app便宜
  • 受欢迎的网站开发微信开发流程四步
  • 手机做网站的步骤成都网站建设博客
  • 阿里巴巴的网站怎么做的外贸公司起名
  • 上海工程建设造价信息网站品牌营销策划有限公司
  • 佛山做礼物的网站做小程序商城
  • php网站模板下载ppt素材免费网站
  • 在百度网站备案查询上显示未备案是什么意思wordpress插件漏洞利用
  • 运城网站制作公司网站开发制作合同
  • 漳州市城乡建设局网站工程项目管理软件app
  • 厦门营销型网站买网站服务器要多少钱
  • 找人开发软件去什么网站广州app定制公司
  • 做钢材的都用什么网站郑州市域名服务公司
  • 单页面网站怎么优化每天做特卖的网站是哪个
  • 十大创意网站中国建筑官网一测
  • 大连龙采做网站行不行怎么是营销型网站建设
  • 网站管理助手哪个好用创作服务平台