,以后注意,以后注意。
我之前data函数里显示文本的时候采用了Qt::Display方式,这样的话就导致了这个问题的出现,后来我干脆把它去掉,结果呢文本的内容是可以被选中,没办法了,最后用Qt::Display || Qt::Editrole,结果成功了,哈哈。
QVariant PluginModel::data( const QModelIndex &index, int role ) const
{
if (!index.isValid())
return QVariant();
if (role == Qt::TextAlignmentRole)
{
return int(Qt::AlignRight | Qt::AlignVCenter);
}
else if (role == Qt::DisplayRole || role == Qt::EditRole) //就是这个地方
{
switch ( index.column() )
{
case 0: return QString::fromStdString(pluginObjects.at(index.row()).uuid());
case 1: return QString::fromStdString(pluginObjects.at(index.row()).name());
case 2: return QString::fromStdString(pluginObjects.at(index.row()).description());
case 3: return pluginObjects.at(index.row()).platform();
case 4: return QString::fromStdString(pluginObjects.at(index.row()).version());
case 5: return QString::fromStdString(pluginObjects.at(index.row()).modidate());
}
}
return QVariant();
}