QTableView锁定选区
【摘要】 不错的qt线程启动暂停停止的实现方法:具体实现参考:https://codereview.stackexchange.com/questions/26724/thread-pausing-resuming-canceling-with-qtQItemDelegate绘制图片m_image = new QImage(":/xxxx.png");...painter->drawImage(opt...
不错的qt线程启动暂停停止的实现方法:
具体实现参考:
https://codereview.stackexchange.com/questions/26724/thread-pausing-resuming-canceling-with-qt
QItemDelegate绘制图片
m_image = new QImage(":/xxxx.png");
...
painter->drawImage(option.rect,*m_image);
QTableView锁定选区的一个实现思路
在子类中重写虚函数selectionChanged
void xxxTableView::selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
{
if(isLocked){
bool oldstate = this->blockSignals(true);
bool oldstate1 = this->selectionModel()->blockSignals(true);
this->selectionModel()->select(selected, QItemSelectionModel::Deselect);
this->selectionModel()->select(deselected, QItemSelectionModel::Select);
this->blockSignals(oldstate);
this->selectionModel()->blockSignals(oldstate1);
}else{
//emit onViewSelectionChanged(this->selectedIndexes());//如果需要捕捉选区变化,注意这里没有使用selected
}
viewport()->update();
}
void xxxTableView::setSelectQuiet(QRect &rect)//忽略当前锁定设置的选择
{
bool oldstate = this->blockSignals(true);
bool oldstate1 = this->selectionModel()->blockSignals(true);
QModelIndex topLeft = this->model()->index(rect.top(),rect.left());
QModelIndex bottomRight = this->model()->index(rect.bottom(),rect.right());
QItemSelection se(topLeft,bottomRight);
this->selectionModel()->select(se,QItemSelectionModel::Select);
this->blockSignals(oldstate);
this->selectionModel()->blockSignals(oldstate1);
}
std::queue下标索引
https://stackoverflow.com/questions/5877504/access-c-queue-elements-like-an-array
/*--------------------------------------------其他------------------------------------------------------------*/
最近犯的几个错误:
队列元素采用变量缓存后,对缓存变量做自增自减操作,问题是每次再缓存时又重新覆盖;
类中包含指针成员时,尽量使用赋值而不是memcpy,触发有大批量的并且有性能要求,同样的包括拷贝构造;
【声明】本内容来自华为云开发者社区博主,不代表华为云及华为云开发者社区的观点和立场。转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息,否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)