本文整理汇总了C++中QTreeWidgetItem::toolTip方法的典型用法代码示例。如果您正苦于以下问题:C++ QTreeWidgetItem::toolTip方法的具体用法?C++ QTreeWidgetItem::toolTip怎么用?C++ QTreeWidgetItem::toolTip使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTreeWidgetItem
的用法示例。
在下文中一共展示了QTreeWidgetItem::toolTip方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onModifyMacroAction
void DlgCustomKeyboardImp::onModifyMacroAction(const QByteArray& macro)
{
QVariant data = categoryBox->itemData(categoryBox->currentIndex(), Qt::UserRole);
QString group = data.toString();
if (group == QLatin1String("Macros"))
{
CommandManager & cCmdMgr = Application::Instance->commandManager();
Command* pCmd = cCmdMgr.getCommandByName(macro);
for (int i=0; i<commandTreeWidget->topLevelItemCount(); i++) {
QTreeWidgetItem* item = commandTreeWidget->topLevelItem(i);
QByteArray command = item->data(1, Qt::UserRole).toByteArray();
if (command == macro) {
item->setText(1, QString::fromUtf8(pCmd->getMenuText()));
item->setToolTip(1, QString::fromUtf8(pCmd->getToolTipText()));
item->setData(1, Qt::UserRole, macro);
item->setSizeHint(0, QSize(32, 32));
item->setBackgroundColor(0, Qt::lightGray);
if (pCmd->getPixmap())
item->setIcon(0, BitmapFactory().iconFromTheme(pCmd->getPixmap()));
if (commandTreeWidget->isItemSelected(item))
textLabelDescription->setText(item->toolTip(1));
break;
}
}
}
}
示例2: toolTip
QString QTreeWidgetItemProto::toolTip(int column) const
{
QTreeWidgetItem *item = qscriptvalue_cast<QTreeWidgetItem*>(thisObject());
if (item)
return item->toolTip(column);
return QString();
}
示例3: getCurrentFile
QString ImportOptionsDlg::getCurrentFile() const
{
QString filename;
map<ImportDescriptor*, QTreeWidgetItem*>::const_iterator iter = mDatasets.find(mpCurrentDataset);
if (iter != mDatasets.end())
{
QTreeWidgetItem* pDatasetItem = iter->second;
if (pDatasetItem != NULL)
{
QTreeWidgetItem* pFileItem = pDatasetItem->parent();
if (pFileItem != NULL)
{
filename = pFileItem->toolTip(0);
}
}
}
return filename;
}
示例4: while
void
ShowParameters::OnShow()
{
m_ui->treeWidget->clear();
for( int i = 0; i < mrParamList.Size(); ++i )
{
const HierarchicalLabel& path = mrParamList[i].Sections();
QTreeWidgetItem* pParent = m_ui->treeWidget->invisibleRootItem();
for( size_t j = 0; j < min( cMaxTreeDepth - 1, path.size() ); ++j )
{
int c = 0;
while( c < pParent->childCount() )
{
if( pParent->child( c )->text( 0 ) == path[j].c_str() )
break;
else
++c;
}
if( c < pParent->childCount() )
{
pParent = pParent->child( c );
}
else
{
pParent = new QTreeWidgetItem( pParent, QStringList( path[j].c_str() ) );
pParent->setFlags( Qt::ItemIsUserCheckable | Qt::ItemIsTristate | Qt::ItemIsEnabled );
pParent->setCheckState( 0, Qt::PartiallyChecked );
AdjustSize( pParent, cTextMargin );
}
}
const char* pName = mrParamList[i].Name().c_str();
QTreeWidgetItem* pItem = new QTreeWidgetItem( pParent, QStringList( pName ) );
pItem->setToolTip( 0, QString::fromLocal8Bit( mrParamList[i].Comment().c_str() ) );
pItem->setWhatsThis( 0, pItem->toolTip( 0 ) );
pItem->setFlags( Qt::ItemIsUserCheckable | Qt::ItemIsEnabled );
pItem->setCheckState( 0, OperatorUtils::GetFilterStatus( pName, mFilterType ) ? Qt::Unchecked : Qt::Checked );
AdjustSize( pItem, cTextMargin );
}
m_ui->treeWidget->resizeColumnToContents( 0 );
mChanged = false;
}
示例5: updateTreeListData
void MainWindow::updateTreeListData()
{
entitySelector->clear();
for(int i = 0; i < g_entitylist.size(); ++i) {
QTreeWidgetItem* item = new QTreeWidgetItem(entitySelector);
item->setText(0, g_entitylist.at(i).mName);
item->setText(2, QString::number(i));
switch(g_entitylist.at(i).typeId()) {
case ENTITY_ENEMY:
item->setText(1, tr("Inimigo"));
item->setToolTip(0,
"<table>" +
QString("<tr><td><b>HP:</b></td> <td>%1</td></tr>"
"<tr><td><b>MP:</b></td> <td>%2</td></tr>"
"<tr><td><b>Ataque:</b></td> <td>%3</td></tr>"
"<tr><td><b>Defesa:</b></td> <td>%4</td></tr>"
"<tr><td><b>Range:</b></td> <td>%5</td></tr>"
"<tr><td><b>Delay:</b></td> <td>%6</td></tr>"
)
.arg(g_entitylist.at(i).mHp).arg(g_entitylist.at(i).mMp)
.arg(g_entitylist.at(i).mAtk).arg(g_entitylist.at(i).mDef)
.arg(g_entitylist.at(i).mRange).arg(g_entitylist.at(i).mDelay)+
"</table>"
);
item->setToolTip(1, item->toolTip(0));
break;
case ENTITY_ITEM:
item->setText(1, tr("Item"));
item->setToolTip(0,
"<table>" +
QString("<tr><td><b>HP:</b></td> <td>%1</td></tr>"
"<tr><td><b>MP:</b></td> <td>%2</td></tr>"
"<tr><td><b>Ataque:</b></td> <td>%3</td></tr>"
"<tr><td><b>Defesa:</b></td> <td>%4</td></tr>"
)
.arg(g_entitylist.at(i).mHp).arg(g_entitylist.at(i).mMp)
.arg(g_entitylist.at(i).mAtk).arg(g_entitylist.at(i).mDef) +
"</table>"
);
item->setToolTip(1, item->toolTip(0));
break;
case ENTITY_GOLD:
item->setText(1, tr("Dinheiro"));
item->setToolTip(0,
"<table>" +
QString("<tr><td><b>Gold:</b></td> <td>%1</td></tr>"
)
.arg(g_entitylist.at(i).mGold)+
"</table>"
);
item->setToolTip(1, item->toolTip(0));
break;
default:
item->setText(1, tr("Indefinido"));
}
// item->setToolTip(0,
// "<html>"
// "<div style=\"32px; height: 32px; overflow: hidden;\">"
// "<img src='data/chars.png' style=\"position: absolute; left:-37px;\"/>"
// "</div>"
// "</html>");
}
}
示例6: event
//.........这里部分代码省略.........
}
}
break;
default:
break;
}
}
break;
case QEvent::Resize: {
QResizeEvent * re = (QResizeEvent *)event;
if (!_inResize && re->oldSize() != re->size()) {
if (_stretchingColumn != -1 && columnCount()) {
QList< int > columnsSizes;
int oldSize = 0;
for (int i = 0; i != header()->count(); i++) {
columnsSizes.append(header()->sectionSize(i));
oldSize += header()->sectionSize(i);
}
bool res = QTreeWidget::event(event);
int newSize = viewport()->width();
int delta = newSize - oldSize;
if (delta) {
_inResize = true;
for (int i = 0; i != header()->count(); i++) {
if (i == _stretchingColumn) {
int newNs = columnsSizes[ i ] + delta;
if (newNs < 8)
newNs = 8;
header()->resizeSection(i, newNs);
} else if (header()->sectionSize(i) != columnsSizes[ i ]) {
header()->resizeSection(i, columnsSizes[ i ]);
}
}
_inResize = false;
}
return res;
}
}
break;
}
case QEvent::ToolTip: {
QHelpEvent *he = static_cast<QHelpEvent*>(event);
if (viewport()) {
QPoint pos = viewport()->mapFromGlobal(he->globalPos());
QTreeWidgetItem * item = itemAt(pos);
int column = columnAt(pos.x());
if (item) {
if (!item->toolTip(column).isEmpty())
break;
QString tip = item->text(column);
int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;
int requiredWidth = QFontMetrics(font()).width(tip) + 2 * textMargin;
if (column == 0 && indentation()) {
int level = 0;
QTreeWidgetItem *parent = item;
while ((parent = parent->parent()))
level++;
if (rootIsDecorated())
level++;
requiredWidth += level * indentation();
}
QIcon icon = item->icon(column);
if (!icon.isNull()) {
QStyleOptionViewItem opts = viewOptions();
QSize iconSize = icon.actualSize(opts.decorationSize);
requiredWidth += iconSize.width();
int pixmapMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, this) + 1;
requiredWidth += 2 * pixmapMargin;
}
if (!tip.isEmpty() && (columnWidth(column) < requiredWidth))
QToolTip::showText(he->globalPos(), tip, this);
return true;
}
}
}
break;
default:
break;
}
return QTreeWidget::event(event);
}