简体   繁体   English

QTableView强制选择一个单元格

[英]QTableView force one cell selection

I want the user to be able to select only one cell at time. 我希望用户一次只能选择一个单元格。 How can I set the maximum possible selection of cells of a QTableView to 1 (c++) ? 如何将QTableView的单元格的最大可能选择设置为1(c ++)?

Set selectionMode to SingleSelection and set selectionBehavior to SelectItems selectionMode设置为SingleSelection并将selectionBehavior设置为SelectItems

在此处输入图片说明

tableView->setSelectionMode(QAbstractItemView::SingleSelection);
tableView->setSelectionBehavior(QAbstractItemView::SelectItems);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM