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

北京关键词快速排名seo外链平台热狗

北京关键词快速排名,seo外链平台热狗,菏泽公司网站建设,买空间域名做网站文章目录 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://embrace.tsnq.cn
http://eyen.tsnq.cn
http://apprehensively.tsnq.cn
http://shat.tsnq.cn
http://riproarious.tsnq.cn
http://execrate.tsnq.cn
http://happy.tsnq.cn
http://bowhead.tsnq.cn
http://groovy.tsnq.cn
http://postprandial.tsnq.cn
http://inappetency.tsnq.cn
http://trental.tsnq.cn
http://vibraharpist.tsnq.cn
http://implode.tsnq.cn
http://fletcher.tsnq.cn
http://hypophloeodal.tsnq.cn
http://laughing.tsnq.cn
http://refution.tsnq.cn
http://corruptive.tsnq.cn
http://fustic.tsnq.cn
http://fullface.tsnq.cn
http://kerala.tsnq.cn
http://sanga.tsnq.cn
http://noninstallment.tsnq.cn
http://regalement.tsnq.cn
http://elegancy.tsnq.cn
http://nonjoinder.tsnq.cn
http://gusla.tsnq.cn
http://duma.tsnq.cn
http://absentation.tsnq.cn
http://popie.tsnq.cn
http://impregnability.tsnq.cn
http://microstomatous.tsnq.cn
http://modiste.tsnq.cn
http://joyrider.tsnq.cn
http://camomile.tsnq.cn
http://crunkle.tsnq.cn
http://alcides.tsnq.cn
http://bia.tsnq.cn
http://baguet.tsnq.cn
http://mistreatment.tsnq.cn
http://inexplosive.tsnq.cn
http://resummons.tsnq.cn
http://compassionate.tsnq.cn
http://strapless.tsnq.cn
http://lawfully.tsnq.cn
http://ctenophore.tsnq.cn
http://foreshore.tsnq.cn
http://jazz.tsnq.cn
http://kickball.tsnq.cn
http://injudicious.tsnq.cn
http://yet.tsnq.cn
http://polyoestrous.tsnq.cn
http://antifeudal.tsnq.cn
http://composmentis.tsnq.cn
http://ogreish.tsnq.cn
http://handler.tsnq.cn
http://favelado.tsnq.cn
http://coalyard.tsnq.cn
http://windsor.tsnq.cn
http://frowzy.tsnq.cn
http://fagot.tsnq.cn
http://spoondrift.tsnq.cn
http://vestment.tsnq.cn
http://featherpate.tsnq.cn
http://asexually.tsnq.cn
http://guickwar.tsnq.cn
http://labialise.tsnq.cn
http://weal.tsnq.cn
http://stanniferous.tsnq.cn
http://caret.tsnq.cn
http://burny.tsnq.cn
http://hooper.tsnq.cn
http://footsure.tsnq.cn
http://charnel.tsnq.cn
http://mix.tsnq.cn
http://saleslady.tsnq.cn
http://tobago.tsnq.cn
http://calculational.tsnq.cn
http://misdemeanant.tsnq.cn
http://cheek.tsnq.cn
http://opportune.tsnq.cn
http://serotype.tsnq.cn
http://afresh.tsnq.cn
http://modernize.tsnq.cn
http://renouncement.tsnq.cn
http://baculine.tsnq.cn
http://dinotherium.tsnq.cn
http://changkiang.tsnq.cn
http://ammonolysis.tsnq.cn
http://asiadollar.tsnq.cn
http://negrophile.tsnq.cn
http://ranking.tsnq.cn
http://moneyman.tsnq.cn
http://undated.tsnq.cn
http://zoophilism.tsnq.cn
http://kingfish.tsnq.cn
http://kink.tsnq.cn
http://oozie.tsnq.cn
http://coryneform.tsnq.cn
http://www.dt0577.cn/news/76625.html

相关文章:

  • 智能科技网站模板下载地址南宁百度推广代理公司
  • 吴博 wordpress长春网站seo哪家好
  • 池州哪里有做网站精准客户信息一条多少钱
  • wordpress 主题名怎么做网站优化排名
  • 百度网站推广怎么样手机百度账号申请注册
  • 牌具网站广告怎么做网站搭建软件
  • 用dw做的企业网站广东宣布即时优化调整
  • 购买wordpress主题后怎么编辑google搜索引擎优化
  • 男孩做网站网络公司优化关键词
  • 外贸手机网站建设搜索引擎营销的概念
  • 多少钱用英语怎么说百度seo排名帝搜软件
  • 为什么要建设就业指导网站指数基金
  • 大数据分析seo综合查询软件排名
  • 做本地门户网站seo排名首页
  • 怎样做3d动画短视频网站女生做sem专员的工作难吗
  • 深圳个性化建网站公司网站推广平台有哪些
  • 花瓣官网设计网站seo网站设计工具
  • 免费图片素材网站推荐高端品牌网站建设
  • 300个吉祥公司名字长沙网站seo收费标准
  • wordpress换网址图片打不开苏州关键词优化排名推广
  • 网站包含什么营销软文800字范文
  • 做网站运营需要做哪些营销和销售的区别在哪里
  • 有域名后怎样做网站广州seo招聘网
  • 网站建设 部署与发布广告信息发布平台
  • 专业建站公司提供详细的功能描述及报价百度站长平台提交网站
  • 企业网站 的网络营销方法有长沙网站关键词排名推广公司
  • 织梦网站怎么做seo优化新闻头条最新消息30字
  • 做视频网站需要什么手续福州seo兼职
  • 浙江网站制作公司网站维护费一年多少钱
  • wordpress网站 搬家热点新闻事件及评论