QComboBox 下拉菜单某行不显示

void hideComboBoxRow(QComboBox *combox,int nRow)
{
	if (NULL == combox) return;
	if (QStandardItemModel *m = qobject_cast<QStandardItemModel*>(combox->model())) {
		QStandardItem *hiddenRoot = m->invisibleRootItem();
		//设置不显示
		hiddenRoot->child(nRow, 0)->setSizeHint(QSize(0, 0));
		//设置不可用
		hiddenRoot->child(nRow, 0)->setEnabled(false);
		//切换当前显示
		combox->setCurrentIndex(-1);
	}
}
//设置固定高度,防止下拉显示框缩小
combox->view()->setMinimumHeight(100);
发布了38 篇原创文章 · 获赞 4 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/sinat_31964903/article/details/88828485