当前位置: 首页>>代码示例>>C++>>正文


C++ QTreeWidgetItem::toolTip方法代码示例

本文整理汇总了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;
            }
        }
    }
}
开发者ID:Jeremywoo,项目名称:FreeCAD,代码行数:26,代码来源:DlgKeyboardImp.cpp

示例2: toolTip

QString QTreeWidgetItemProto::toolTip(int column)	        const
{
  QTreeWidgetItem *item = qscriptvalue_cast<QTreeWidgetItem*>(thisObject());
  if (item)
    return item->toolTip(column);
  return QString();
}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例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;
}
开发者ID:Siddharthk,项目名称:opticks,代码行数:20,代码来源:ImportOptionsDlg.cpp

示例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;
}
开发者ID:ACrazyer,项目名称:NeuralSystemsBCI2000,代码行数:41,代码来源:ShowParameters.cpp

示例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>");
    }
}
开发者ID:GustJc,项目名称:QtMapBuilder,代码行数:65,代码来源:mainwindow.cpp

示例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);
}
开发者ID:aremai,项目名称:krusader,代码行数:101,代码来源:krtreewidget.cpp


注:本文中的QTreeWidgetItem::toolTip方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。