本文整理汇总了C++中QTableWidgetItem::setToolTip方法的典型用法代码示例。如果您正苦于以下问题:C++ QTableWidgetItem::setToolTip方法的具体用法?C++ QTableWidgetItem::setToolTip怎么用?C++ QTableWidgetItem::setToolTip使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTableWidgetItem
的用法示例。
在下文中一共展示了QTableWidgetItem::setToolTip方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: showFiles
//! [8]
void Window::showFiles(const QStringList &paths) {
for (const QString &filePath : paths) {
const QString toolTip = QDir::toNativeSeparators(filePath);
const QString relativePath =
QDir::toNativeSeparators(currentDir.relativeFilePath(filePath));
const qint64 size = QFileInfo(filePath).size();
QTableWidgetItem *fileNameItem = new QTableWidgetItem(relativePath);
fileNameItem->setData(absoluteFileNameRole, QVariant(filePath));
fileNameItem->setToolTip(toolTip);
fileNameItem->setFlags(fileNameItem->flags() ^ Qt::ItemIsEditable);
QTableWidgetItem *sizeItem =
new QTableWidgetItem(QLocale().formattedDataSize(size));
sizeItem->setData(absoluteFileNameRole, QVariant(filePath));
sizeItem->setToolTip(toolTip);
sizeItem->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
sizeItem->setFlags(sizeItem->flags() ^ Qt::ItemIsEditable);
int row = filesTable->rowCount();
filesTable->insertRow(row);
filesTable->setItem(row, 0, fileNameItem);
filesTable->setItem(row, 1, sizeItem);
}
filesFoundLabel->setText(tr(
"%n file(s) found (Double click on a file to open it)", 0, paths.size()));
filesFoundLabel->setWordWrap(true);
}
示例2: creatSearchedItems
void MusicLrcSearchTableWidget::creatSearchedItems(const QString &songname,
const QString &artistname, const QString &time)
{
int count;
setRowCount(count = m_downLoadManager->getSongIdIndex());
QTableWidgetItem *item = new QTableWidgetItem;
item->setData(MUSIC_CHECK_ROLE, false);
setItem(count - 1, 0, item);
item = new QTableWidgetItem;
item->setText(QFontMetrics(font()).elidedText(songname, Qt::ElideRight, 170));
item->setTextColor(QColor(50, 50, 50));
item->setTextAlignment(Qt::AlignCenter);
item->setToolTip(songname);
setItem(count - 1, 1, item);
item = new QTableWidgetItem;
item->setText(QFontMetrics(font()).elidedText(artistname, Qt::ElideRight, 144));
item->setTextColor(QColor(50, 50, 50));
item->setTextAlignment(Qt::AlignCenter);
item->setToolTip(artistname);
setItem(count - 1, 2, item);
item = new QTableWidgetItem(time);
item->setTextColor(QColor(50, 50, 50));
item->setTextAlignment(Qt::AlignCenter);
setItem(count - 1, 3, item);
item = new QTableWidgetItem;
item->setIcon(QIcon(QString::fromUtf8(":/radio/collect")));
setItem(count - 1, 4, item);
}
示例3: addRow
void ColorListWidget::addRow(int row)
{
react_to_changes = false;
QTableWidgetItem* item;
for (int col = 0; col < color_table->columnCount(); ++col)
{
item = new QTableWidgetItem();
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
// TODO: replace "define" with "edit"
item->setToolTip(tr("Double click to define the color"));
color_table->setItem(row, col, item);
}
#if 0 // Interfers with translation
// Name
item = color_table->item(row, 1);
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
item->setToolTip(tr("Click to select the name and click again to edit."));
#endif
// Opacity
item = color_table->item(row, 6);
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
react_to_changes = true;
updateRow(row);
}
示例4: createAllItems
void MusicConnectTransferWidget::createAllItems(const MusicSongs &songs)
{
ui->playListTableWidget->clear();
if(ui->allSelectedcheckBox->isChecked())
{
ui->allSelectedcheckBox->click();
}
ui->playListTableWidget->setRowCount(songs.count());
for(int i=0; i<songs.count(); ++i)
{
MusicSong song = songs[i];
QTableWidgetItem *item = new QTableWidgetItem;
item->setData(MUSIC_CHECK_ROLE, false);
ui->playListTableWidget->setItem(i, 0, item);
item = new QTableWidgetItem;
item->setText(QFontMetrics(font()).elidedText(song.getMusicName(), Qt::ElideRight, 280));
item->setToolTip(song.getMusicPath());
item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
ui->playListTableWidget->setItem(i, 1, item);
item = new QTableWidgetItem;
item->setText(QFontMetrics(font()).elidedText(song.getMusicTime(), Qt::ElideRight, 40));
item->setToolTip(song.getMusicTime());
item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
ui->playListTableWidget->setItem(i, 2, item);
}
}
示例5: creatSearchedItems
void MusicLrcSearchTableWidget::creatSearchedItems(const QString &songname,
const QString &artistname, const QString &time)
{
int count;
setRowCount(count = m_downLoadManager->getSongIdIndex());
setStyleSheet(MusicUIObject::MTableWidgetStyle01 + \
MusicUIObject::MScrollBarStyle01);
QTableWidgetItem *item = new QTableWidgetItem;
item->setData(Qt::DisplayRole, false);
setItem(count - 1, 0, item);
item = new QTableWidgetItem(songname);
item->setTextColor(QColor(50, 50, 50));
item->setTextAlignment(Qt::AlignCenter);
item->setToolTip(songname);
setItem(count - 1, 1, item);
item = new QTableWidgetItem(artistname);
item->setTextColor(QColor(50, 50, 50));
item->setTextAlignment(Qt::AlignCenter);
item->setToolTip(artistname);
setItem(count - 1, 2, item);
item = new QTableWidgetItem(time);
item->setTextColor(QColor(50, 50, 50));
item->setTextAlignment(Qt::AlignCenter);
setItem(count - 1, 3, item);
item = new QTableWidgetItem(QIcon(QString::fromUtf8(":/radio/collect")), "");
item->setTextAlignment(Qt::AlignCenter);
setItem(count - 1, 4, item);
}
示例6: LoadContent
void DialogEditNodeTable::LoadContent()
{
//Load the element value
m_pValueLine->setText(m_node.toElement().text());
//Get all the attributes
QDomNamedNodeMap attributes = m_node.attributes();
m_pTable->setRowCount(attributes.size());
QTableWidgetItem* item = 0;
//Add each attribute in to the table
for(int indexRow=0; indexRow < attributes.size(); ++indexRow)
{
int columnIndex = 0;
QDomAttr attributeNode = attributes.item(indexRow).toAttr();
item = new QTableWidgetItem(attributeNode.nodeName());// << attribute name
item->setToolTip(attributeNode.nodeName());
m_pTable->setItem(indexRow, columnIndex, item);
columnIndex++;
item = new QTableWidgetItem(attributeNode.nodeValue());// << value
item->setToolTip(attributeNode.nodeValue());
m_pTable->setItem(indexRow, columnIndex, item);
columnIndex++;
}
}
示例7: createFilesTable
static QTableWidget* createFilesTable(const QStringList &fileNames)
{
QTableWidget *table = new QTableWidget(0, 2);
table->setSelectionMode(QAbstractItemView::NoSelection);
QStringList labels({
QCoreApplication::translate("AddImageToResources","Filename"),
QCoreApplication::translate("AddImageToResources","Size")
});
table->setHorizontalHeaderLabels(labels);
table->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
table->verticalHeader()->hide();
table->setShowGrid(false);
for (const QString &filePath : fileNames) {
const QString toolTip = QDir::toNativeSeparators(filePath);
const QString fileName = QFileInfo(filePath).fileName();
const qint64 size = QFileInfo(filePath).size() / 1024;
QTableWidgetItem *fileNameItem = new QTableWidgetItem(fileName);
fileNameItem->setToolTip(toolTip);
fileNameItem->setFlags(fileNameItem->flags() ^ Qt::ItemIsEditable);
QTableWidgetItem *sizeItem = new QTableWidgetItem(QString::number(size) + " KB");
sizeItem->setToolTip(toolTip);
sizeItem->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
sizeItem->setFlags(sizeItem->flags() ^ Qt::ItemIsEditable);
int row = table->rowCount();
table->insertRow(row);
table->setItem(row, 0, fileNameItem);
table->setItem(row, 1, sizeItem);
}
return table;
}
示例8: slot_LoadFinished
//加载完成
void SearchThread::slot_LoadFinished( QNetworkReply *replay )
{
QTextCodec *codec = QTextCodec::codecForName("utf8"); //转换成utf8编码格式
QString searchStr = codec->toUnicode(replay->readAll());
if (searchStr == "")
{
emit sig_SearchTimeout(); //搜索超时
return;
}
searchStr = QUrl::fromPercentEncoding(searchStr.toAscii()); //百分比编码
//解析Json
QJson::Parser parser;
bool ok;
QVariantMap result = parser.parse(searchStr.toUtf8(), &ok).toMap();
if (!ok)
{
qDebug() << "转换成QVariantMap失败";
return;
}
//搜索到的数量
m_nMusicNum = result["total"].toInt();
emit sig_SearchNum(m_nMusicNum);
//得到结果数组
QVariantList resultList = result["results"].toList();
foreach (QVariant var, resultList)
{
QVariantMap resultMap = var.toMap(); //得到每一项的map
//歌曲名
QCheckBox *musicNameCheckBox = new QCheckBox(resultMap["song_name"].toString());
musicNameCheckBox->setObjectName(tr("musicNameCheckBox"));
musicNameCheckBox->setToolTip(resultMap["song_name"].toString());
musicNameCheckBox->setFont(QFont("微软雅黑", 10));
musicNameCheckBox->setStyleSheet("QCheckBox{color:white;}"
"QCheckBox::indicator{width:10px;height:10px;border: 1px solid white;border-radius:2px}"
"QCheckBox::indicator:checked {image: url(:/app/images/checked2.png);}");
//艺人
QTableWidgetItem *artistItem = new QTableWidgetItem(resultMap["artist_name"].toString());
artistItem->setTextAlignment(Qt::AlignCenter);
artistItem->setToolTip(resultMap["artist_name"].toString());
artistItem->setFont(QFont("微软雅黑", 10));
//专辑
QTableWidgetItem *albumItem = new QTableWidgetItem("《" + resultMap["album_name"].toString() + "》");
albumItem->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
albumItem->setToolTip("《" + resultMap["album_name"].toString() + "》");
albumItem->setFont(QFont("微软雅黑", 10));
//插入播放列表
int currentRows = m_searchList->rowCount();//返回列表中的行数
m_searchList->insertRow(currentRows);//从播放列表中的当前行插入
m_searchList->setCellWidget(currentRows, 0, musicNameCheckBox);
m_searchList->setItem(currentRows, 1, artistItem);
m_searchList->setItem(currentRows, 2, albumItem);
}
示例9: fill
void PropertyEditingTable::fill(QDomElement xml,
QMap<QString, QString> values) {
QDomNodeList exprops = xml.elementsByTagName("property");
setRowCount(exprops.count());
for (int k = 0; k < exprops.count(); k++) {
QDomElement exprop = exprops.at(k).toElement();
QTableWidgetItem *item;
item = new QTableWidgetItem(exprop.attribute("title"));
QString propDesc = exprop.attribute("description");
item->setFlags(Qt::ItemIsEnabled);
if (!propDesc.isEmpty())
item->setToolTip(propDesc);
setItem(k, 0, item);
QString val = exprop.attribute("default");
QString propKey = exprop.attribute("name");
QString propType = exprop.attribute("type");
if (values.contains(propKey))
val = values[propKey];
PropDesc pdesc;
pdesc.name=propKey;
pdesc.type=propType;
pdesc.value=val;
props.append(pdesc);
if (propType == "boolean") {
QCheckBox *cb = new QCheckBox("");
cb->setChecked(val.toInt() != 0);
if (!propDesc.isEmpty())
cb->setToolTip(propDesc);
setCellWidget(k, 1, cb);
} else {
item = new QTableWidgetItem(val);
if (!propDesc.isEmpty())
item->setToolTip(propDesc);
setItem(k, 1, item);
}
if ((propType == "dir")||(propType == "file")) {
QPushButton *bt = new QPushButton("Browse");
mapper->setMapping(bt, k);
connect(bt, SIGNAL(clicked()), mapper, SLOT(map()));
setCellWidget(k, 2, bt);
}
}
horizontalHeader()->resizeSections(QHeaderView::ResizeToContents);
}
示例10: receiveDataFinshed
void MusicCloudSharedSongTableWidget::receiveDataFinshed(const QNDataItems &items)
{
clear();
int count = items.count();
if(count == 0)
{
emit updateLabelMessage(tr("List Is Empty!"));
createUploadFileWidget();
return;
}
delete m_openFileWidget;
m_openFileWidget = nullptr;
setRowCount(count);
QHeaderView *headerview = horizontalHeader();
for(int i=0; i<count; ++i)
{
QNDataItem dataItem = items[i];
QTableWidgetItem *item = new QTableWidgetItem;
item->setData(MUSIC_DATAS_ROLE, QVariant::fromValue<QNDataItem>(dataItem));
setItem(i, 0, item);
item = new QTableWidgetItem;
item->setToolTip(dataItem.m_name);
item->setText(MusicUtils::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerview->sectionSize(1) - 20));
item->setTextColor(QColor(MusicUIObject::MColorStyle12_S));
item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
setItem(i, 1, item);
item = new QTableWidgetItem;
item->setToolTip(MusicUtils::Number::size2Label(dataItem.m_size));
item->setText(MusicUtils::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerview->sectionSize(2) - 5));
item->setTextColor(QColor(MusicUIObject::MColorStyle12_S));
item->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
setItem(i, 2, item);
///insert server datas into caches
MusicUploadData data;
data.m_path = dataItem.m_name.trimmed();
data.m_name = data.m_path;
data.m_state = MusicUploadData::Successed;
if(!m_waitedFiles.contains(data))
{
m_waitedFiles << data;
}
}
m_currentUploadIndex = m_waitedFiles.count();
emit updateLabelMessage(tr("List Update Finished!"));
}
示例11: creatSearchedItems
void MusicVideoTableWidget::creatSearchedItems(const QString &songname,
const QString &artistname,
const QString &time)
{
int count;
setRowCount(count = m_downLoadManager->getSongIdIndex());
QHeaderView *headerview = horizontalHeader();
QTableWidgetItem *item = new QTableWidgetItem;
item->setData(MUSIC_CHECK_ROLE, false);
setItem(count - 1, 0, item);
item = new QTableWidgetItem;
item->setText(QFontMetrics(font()).elidedText(songname, Qt::ElideRight,
headerview->sectionSize(1) - 5));
item->setTextColor(QColor(50, 50, 50));
item->setTextAlignment(Qt::AlignCenter);
item->setToolTip(songname);
setItem(count - 1, 1, item);
item = new QTableWidgetItem;
item->setText(QFontMetrics(font()).elidedText(artistname, Qt::ElideRight,
headerview->sectionSize(2) - 5));
item->setTextColor(QColor(50, 50, 50));
item->setTextAlignment(Qt::AlignCenter);
item->setToolTip(artistname);
setItem(count - 1, 2, item);
item = new QTableWidgetItem;
item->setIcon(QIcon(randToGetStrength()));
setItem(count - 1, 3, item);
item = new QTableWidgetItem(time);
item->setTextColor(QColor(50, 50, 50));
item->setTextAlignment(Qt::AlignCenter);
setItem(count - 1, 4, item);
item = new QTableWidgetItem;
item->setIcon(QIcon(QString::fromUtf8(":/share/showMV")));
setItem(count - 1, 5, item);
item = new QTableWidgetItem;
item->setIcon(QIcon(QString::fromUtf8(":/share/autionplay")));
setItem(count - 1, 6, item);
item = new QTableWidgetItem;
item->setIcon(QIcon(QString::fromUtf8(":/share/musicdownload")));
setItem(count - 1, 7, item);
}
示例12: insertPage
/*!
Inserts a \a page with \a icon and \a title at \a index.
In case \a title is an empty string, QWidget::windowTitle of \a page is used.
Returns the index of inserted page.
\warning Inserting and removing pages dynamically at run time might cause flicker.
\sa addPage()
*/
int QxtConfigWidget::insertPage(int index, QWidget* page, const QIcon& icon, const QString& title)
{
if (!page)
{
qWarning("QxtConfigWidget::insertPage(): Attempt to insert null page");
return -1;
}
index = qxt_d().stack->insertWidget(index, page);
const QString label = !title.isEmpty() ? title : page->windowTitle();
if (label.isEmpty())
qWarning("QxtConfigWidget::insertPage(): Inserting a page with an empty title");
QTableWidgetItem* item = new QTableWidgetItem(icon, label);
item->setToolTip(label);
if (qxt_d().pos == QxtConfigWidget::North)
{
qxt_d().table->model()->insertColumn(index);
qxt_d().table->setItem(0, index, item);
qxt_d().table->resizeRowToContents(0);
}
else
{
qxt_d().table->model()->insertRow(index);
qxt_d().table->setItem(index, 0, item);
qxt_d().table->resizeColumnToContents(0);
}
qxt_d().table->updateGeometry();
return index;
}
示例13: UpdateWarning
void FieldEditPanel::UpdateWarning(int row)
{
soc_word_t val = m_ref.GetField().value[row].value;
soc_word_t max = m_ref.GetField().bitmask() >> m_ref.GetField().first_bit;
QTableWidgetItem *item = m_value_table->item(row, FieldValueValueColumn);
if(val > max)
{
item->setIcon(QIcon::fromTheme("dialog-warning"));
item->setToolTip("Value is too big for the field");
}
else
{
item->setIcon(QIcon());
item->setToolTip("");
}
}
示例14: do_update
void items::do_update()
{
const QList<data::item>& items = resource_->items();
int size = items.size();
data_->clearContents();
data_->setRowCount(size);
for (int i = 0; i < size; ++i)
{
data::item res = items.at(i);
QTableWidgetItem* tfn = new QTableWidgetItem(res.filename_);
tfn->setData(Qt::UserRole, QVariant(res.id_));
tfn->setToolTip(res.filename_);
data_->setItem(i, 0, tfn);
QTableWidgetItem* tt = new QTableWidgetItem(resource_->str_type_item(res.type_));
tt->setData(Qt::UserRole, QVariant(res.id_));
data_->setItem(i, 1, tt);
QTableWidgetItem* to = new QTableWidgetItem();
to->setData(Qt::UserRole, QVariant(res.id_));
data_->setItem(i, 2, to);
}
}
示例15: updateTestJobSetting
void CTestSettingWindow::updateTestJobSetting()
{
QVector<testRecord> t = ((CApp*)qApp)->_meter->_tr;
_resultText->setText(tr("仪表的检测记录如下:(点亮项为本次测试,其它为过往测试,双击选择一条记录开始测试!)"));
_resultText->setStyleSheet("font:bold 14px;color:#0099FF;max-height:26px;min-height:26px;background:#CCFF99;padding:0 15px;");
_thirdGroup->setVisible(true);
QString r1,r2,r3,r4;
_testList->clearContents();
_testList->setRowCount(t.size());
for(int i = 0; i != t.size() ; ++i)
{
r1 = QString::number(getTestSucessPercentage(INIT_TEST_COUNT,t[i]._inittest)) + "%";
r2 = QString::number(getTestSucessPercentage(FULL_TEST_COUNT,t[i]._fulltest)) + "%";
r3 = QString::number(getTestSucessPercentage(ADJUST_TEST_COUNT,t[i]._adjusttest)) + "%";
r4 = QString::number(getTestSucessPercentage(FUNCTION_TEST_COUNT,t[i]._functiontest)) + "%";
_testList->setItem(i,0,new QTableWidgetItem(QString::number(t[i]._id)));
_testList->setItem(i,1,new QTableWidgetItem(QDateTime::fromTime_t(t[i]._date).toString("yyyy-MM-dd hh:mm:ss")));
_testList->setItem(i,2,new QTableWidgetItem(t[i]._user));
_testList->setItem(i,3,new QTableWidgetItem(r1));
_testList->setItem(i,4,new QTableWidgetItem(r2));
_testList->setItem(i,5,new QTableWidgetItem(r3));
_testList->setItem(i,6,new QTableWidgetItem(r4));
QTableWidgetItem* comment = new QTableWidgetItem(t[i]._comment);
comment->setToolTip(t[i]._comment);
_testList->setItem(i,7,comment);
}
_testList->sortItems(1, Qt::DescendingOrder);
_testList->selectRow(0);
_testList->resizeColumnsToContents();
_testList->resizeRowsToContents();
}