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


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

本文整理汇总了C++中QAction::toolTip方法的典型用法代码示例。如果您正苦于以下问题:C++ QAction::toolTip方法的具体用法?C++ QAction::toolTip怎么用?C++ QAction::toolTip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QAction的用法示例。


在下文中一共展示了QAction::toolTip方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: event

bool RiuToolTipMenu::event(QEvent* e)
{
    if (e->type() == QEvent::ToolTip)
    {
        QHelpEvent* he = dynamic_cast<QHelpEvent*>(e);
        QAction* act = actionAt(he->pos());
        if (act)
        {
            // Remove ampersand as this is used to define shortcut key
            QString actionTextWithoutAmpersand = act->text().remove("&");

            if (actionTextWithoutAmpersand != act->toolTip())
            {
                QToolTip::showText(he->globalPos(), act->toolTip(), this);
            }

            return true;
        }
    }
    else if (e->type() == QEvent::Paint && QToolTip::isVisible())
    {
        QToolTip::hideText();
    }

    return QMenu::event(e);
}
开发者ID:OPM,项目名称:ResInsight,代码行数:26,代码来源:RiuToolTipMenu.cpp

示例2: actionText

/*! \reimp */
QString QAccessibleWidget::actionText(int action, Text t, int child) const
{
    if (action == DefaultAction)
        action = SetFocus;

    if (action > 0 && !child) {
        QAction *act = widget()->actions().value(action - 1);
        if (act) {
            switch (t) {
            case Name:
                return act->text();
            case Description:
                return act->toolTip();
#ifndef QT_NO_SHORTCUT
            case Accelerator:
                return act->shortcut().toString();
#endif
            default:
                break;
            }
        }
    }

    return QAccessibleObject::actionText(action, t, child);
}
开发者ID:Arise,项目名称:Open-DPI-Detector,代码行数:26,代码来源:qaccessiblewidget.cpp

示例3: f

    KoGroupButton *addViewButton(KoGroupButton::GroupPosition pos,
                                 Kexi::ViewMode mode, QWidget *parent, const char *slot,
                                 const QString &text, QHBoxLayout *btnLyr)
    {
        if (!window->supportsViewMode(mode)) {
            return 0;
        }
        QAction *a = new KexiToggleViewModeAction(mode, q);
        toggleViewModeActions.insert(mode, a);

        KoGroupButton *btn = new KoGroupButton(pos, parent);
        toggleViewModeButtons.insert(mode, btn);
        connect(btn, SIGNAL(toggled(bool)), q, slot);
        btn->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
        btn->setText(text);
        btn->setIcon(a->icon());
        QFont f(KGlobalSettings::toolBarFont());
        f.setPixelSize(KexiUtils::smallFont().pixelSize());
        btn->setFont(f);
        btn->setToolTip(a->toolTip());
        btn->setWhatsThis(a->whatsThis());
        btn->setCheckable(true);
        btn->setAutoRaise(true);
        btnLyr->addWidget(btn);
        return btn;
    }
开发者ID:crayonink,项目名称:calligra-2,代码行数:26,代码来源:KexiView.cpp

示例4: toolTip

QString QActionProto::toolTip() const
{
  QAction *item = qscriptvalue_cast<QAction*>(thisObject());
  if (item)
    return item->toolTip();
  return QString();
}
开发者ID:Wushaowei001,项目名称:xtuple-1,代码行数:7,代码来源:qactionproto.cpp

示例5: event

// taken from libqtxdg: XdgMenuWidget
bool XdgCachedMenu::event(QEvent* event)
{
    if (event->type() == QEvent::MouseButtonPress)
    {
        QMouseEvent *e = static_cast<QMouseEvent*>(event);
        if (e->button() == Qt::LeftButton)
            mDragStartPosition = e->pos();
    }

    else if (event->type() == QEvent::MouseMove)
    {
        QMouseEvent *e = static_cast<QMouseEvent*>(event);
        handleMouseMoveEvent(e);
    }

    else if(event->type() == QEvent::ToolTip)
    {
        QHelpEvent* helpEvent = static_cast<QHelpEvent*>(event);
        QAction* action = actionAt(helpEvent->pos());
        if(action && action->menu() == NULL)
            QToolTip::showText(helpEvent->globalPos(), action->toolTip(), this);
    }

    return QMenu::event(event);
}
开发者ID:MoonLightDE,项目名称:MoonLightDE,代码行数:26,代码来源:xdgcachedmenu.cpp

示例6: QDialog

ToolbarDialog::ToolbarDialog(QWidget* parent)
    : QDialog(parent),m_defaultToolBars()
{
    setupUi(this);

    createDefaultToolBars();
    // populate all available actions
    QList<QAction*> actions = parent->findChildren<QAction*>(QRegExp("action*"));
    QAction* action;
    foreach(action, actions) {
        if (action->actionGroup()->objectName() != "extraGroup")
            continue;
        QListWidgetItem* item = new QListWidgetItem(action->toolTip());
        item->setIcon(action->icon());
        item->setData(Qt::UserRole, QVariant::fromValue((QObject*)action));
        listAllActions->addItem(item);
    }
    // Important to add special Separator
    listAllActions->addItem("Separator");

    QList<QToolBar*> toolbars = parent->findChildren<QToolBar*>();
    QToolBar* toolbar = NULL;
    int index = 0;
    foreach(toolbar, toolbars) {
        index = (int)(toolbar->iconSize().height()/10)-1;
        if (toolbar->objectName() != "keyToolBar")
            comboToolbars->addItem(toolbar->windowTitle(), QVariant::fromValue((QObject*)toolbar));
    }
开发者ID:adaptee,项目名称:qterm-hack,代码行数:28,代码来源:toolbardialog.cpp

示例7: handleKeyChange

void ProxyAction::handleKeyChange(const QKeySequence &old)
{
    QString oldTooltip(QString("<span style=\"color: gray; font-size: small\">%1</span>").arg(old.toString(QKeySequence::NativeText)));
    QList<QPointer<QAction> > actions(m_contextActions.values());
    QAction *backendAction = 0;

    for (int n = 0; n < actions.count(); n++)
    {
        backendAction = actions.at(n);
        if (backendAction)
        {
            if (backendAction->toolTip().endsWith(oldTooltip))
            {
                QString chopped(backendAction->toolTip());
                chopped.chop(oldTooltip.length());
                backendAction->setToolTip(chopped);
            }
        }
    }

    if (m_currentKey.isEmpty() && !m_defaultKey.isEmpty())
    {
        m_currentKey = m_defaultKey;
    }

    m_action->setShortcut(m_currentKey);

    QString newTooltip(QString("<span style=\"color: gray; font-size: small\">%1</span>").arg(key().toString(QKeySequence::NativeText).toHtmlEscaped()));
    QString activeTooltip(m_activeAction ? m_activeAction->toolTip() : m_backup->toolTip());
    if (m_action->shortcut().isEmpty())
    {
        m_action->setToolTip(activeTooltip);
    }
    else
    {
        m_action->setToolTip(activeTooltip.trimmed() + " " + newTooltip);

        for (int n = 0; n < actions.count(); n++)
        {
            backendAction = actions.at(n);
            if (backendAction)
            {
                backendAction->setToolTip(backendAction->toolTip().trimmed() + " " + newTooltip);
            }
        }
    }
}
开发者ID:jkdoug,项目名称:mudder,代码行数:47,代码来源:proxyaction.cpp

示例8: paintEvent

void StatusBarToolButton::paintEvent(QPaintEvent* event) {
	if (mGroupPosition == NotGrouped) {
		QToolButton::paintEvent(event);
		return;
	}
	QStylePainter painter(this);
	QStyleOptionToolButton opt;
	initStyleOption(&opt);
	QStyleOptionToolButton panelOpt = opt;

	// Panel
	QRect& panelRect = panelOpt.rect;
	switch (mGroupPosition) {
	case GroupLeft:
		panelRect.setWidth(panelRect.width() * 2);
		break;
	case GroupCenter:
		panelRect.setLeft(panelRect.left() - panelRect.width());
		panelRect.setWidth(panelRect.width() * 3);
		break;
	case GroupRight:
		panelRect.setLeft(panelRect.left() - panelRect.width());
		break;
	case NotGrouped:
		Q_ASSERT(0);
	}
	painter.drawPrimitive(QStyle::PE_PanelButtonTool, panelOpt);

	// Separator
	const int y1 = opt.rect.top() + 6;
	const int y2 = opt.rect.bottom() - 6;
	if (mGroupPosition & GroupRight) {
		const int x = opt.rect.left();
		painter.setPen(opt.palette.color(QPalette::Light));
		painter.drawLine(x, y1, x, y2);
	}
	if (mGroupPosition & GroupLeft) {
		const int x = opt.rect.right();
		painter.setPen(opt.palette.color(QPalette::Mid));
		painter.drawLine(x, y1, x, y2);
	}

	// Text
	painter.drawControl(QStyle::CE_ToolButtonLabel, opt);

	// Filtering message on tooltip text for CJK to remove accelerators.
	// Quoting ktoolbar.cpp:
	// """
	// CJK languages use more verbose accelerator marker: they add a Latin
	// letter in parenthesis, and put accelerator on that. Hence, the default
	// removal of ampersand only may not be enough there, instead the whole
	// parenthesis construct should be removed. Provide these filtering i18n
	// messages so that translators can use Transcript for custom removal.
	// """
	if (!actions().isEmpty()) {
		QAction* action = actions().first();
		setToolTip(i18nc("@info:tooltip of custom toolbar button", "%1", action->toolTip()));
	}
}
开发者ID:Elv13,项目名称:Umbrello-ng,代码行数:59,代码来源:statusbartoolbutton.cpp

示例9: event

bool MenuWithToolTips::event (QEvent * e)
{
    const QHelpEvent *helpEvent = static_cast <QHelpEvent *>(e);
    if (helpEvent->type() == QEvent::ToolTip) {
        QAction* action = activeAction();
        if(!action){
            return false;
        }
        if(action->text() != action->toolTip()){

            QToolTip::showText(helpEvent->globalPos(), action->toolTip());
        }
    } else {
        QToolTip::hideText();
    }
    return QMenu::event(e);
}
开发者ID:blackearth2014,项目名称:Natron,代码行数:17,代码来源:MenuWithToolTips.cpp

示例10: getAction

QAction* getAction(Shortcut* s)
      {
      if (s == 0)
            return 0;
      if (s->action == 0) {
            QAction* a = new QAction(s->xml, 0); // mscore);
            s->action  = a;
            a->setData(s->xml);
            if(!s->key.isEmpty())
                a->setShortcut(s->key);
            else
                a->setShortcuts(s->standardKey);
            a->setShortcutContext(s->context);
            if (!s->help.isEmpty()) {
                  a->setToolTip(s->help);
                  a->setWhatsThis(s->help);
                  }
            else {
                  a->setToolTip(s->descr);
                  a->setWhatsThis(s->descr);
                  }
            if (s->standardKey != QKeySequence::UnknownKey) {
                  QList<QKeySequence> kl = a->shortcuts();
                  if (!kl.isEmpty()) {
                        QString s(a->toolTip());
                        s += " (";
                        for (int i = 0; i < kl.size(); ++i) {
                              if (i)
                                    s += ",";
                              s += kl[i].toString(QKeySequence::NativeText);
                              }
                        s += ")";
                        a->setToolTip(s);
                        }
                  }
            else if (!s->key.isEmpty()) {
                  a->setToolTip(a->toolTip() +
                        " (" + s->key.toString(QKeySequence::NativeText) + ")" );
                  }
            if (!s->text.isEmpty())
                  a->setText(s->text);
            if (s->icon != -1)
                  a->setIcon(*icons[s->icon]);
            }
      return s->action;
      }
开发者ID:SSMN,项目名称:MuseScore,代码行数:46,代码来源:shortcut.cpp

示例11: QCheckBox

QCheckBox *OptionsPopup::createCheckboxForCommand(Id id)
{
    QAction *action = ActionManager::command(id)->action();
    QCheckBox *checkbox = new QCheckBox(action->text());
    checkbox->setToolTip(action->toolTip());
    checkbox->setChecked(action->isChecked());
    checkbox->setEnabled(action->isEnabled());
    checkbox->installEventFilter(this); // enter key handling
    QObject::connect(checkbox, &QCheckBox::clicked, action, &QAction::setChecked);
    QObject::connect(action, &QAction::changed, this, &OptionsPopup::actionChanged);
    m_checkboxMap.insert(action, checkbox);
    return checkbox;
}
开发者ID:AgnosticPope,项目名称:qt-creator,代码行数:13,代码来源:findtoolbar.cpp

示例12: adBlock

void WebView::adBlock()
{
	QAction *action = qobject_cast<QAction *>(sender());
	QString url = action->toolTip().replace("http://", "");
	bool ok;
	QString text = QInputDialog::getText(this, tr("Ad Block"),
		tr("Check URL or pattern to block:"), QLineEdit::Normal, url, &ok);
    if (ok && !text.isEmpty())
	{
		NetworkAccessManager* n = BrowserApplication::networkAccessManager();
		n->blockAd( text );
	}
}
开发者ID:OS2World,项目名称:APP-INTERNET-QtWeb,代码行数:13,代码来源:webview.cpp

示例13: getMoveLeftAction

QAction* ControllableSplitter::getMoveLeftAction()
{
	if (!mShiftSplitterLeft)
	{
		QAction* action = new QAction(QIcon(":/icons/open_icon_library/arrow-left-3.png"),
									  QString("Show %1").arg(mRightName), this);
		action->setToolTip(QString("Show more %1").arg(mRightName));
		action->setStatusTip(action->toolTip());
		connect(action, &QAction::triggered, this, &ControllableSplitter::onMoveSplitterLeft);
		mShiftSplitterLeft = action;
		this->enableActions();
	}
	return mShiftSplitterLeft;
}
开发者ID:c0ns0le,项目名称:CustusX,代码行数:14,代码来源:cxControllableSplitter.cpp

示例14: eventFilter

bool FullScreenBar::eventFilter(QObject* object, QEvent* event)
{
    if (event->type() == QEvent::MouseMove) {
        QApplication::restoreOverrideCursor();
        d->mAutoHideCursorTimer->start();
        if (y() == 0) {
            if (d->shouldHide()) {
                slideOut();
            }
        } else {
            QMouseEvent* mouseEvent = static_cast<QMouseEvent *>(event);
            if (mouseEvent->buttons() == 0 && d->slideInTriggerRect().contains(QCursor::pos())) {
                slideIn();
            }
        }
        return false;
    }

    if (event->type() == QEvent::MouseButtonRelease) {
        // This can happen if user released the mouse after using a scrollbar
        // in the content (the bar does not hide while a button is down)
        if (y() == 0 && d->shouldHide()) {
            slideOut();
        }
        return false;
    }

    // Filtering message on tooltip text for CJK to remove accelerators.
    // Quoting ktoolbar.cpp:
    // """
    // CJK languages use more verbose accelerator marker: they add a Latin
    // letter in parenthesis, and put accelerator on that. Hence, the default
    // removal of ampersand only may not be enough there, instead the whole
    // parenthesis construct should be removed. Use KLocale's method to do this.
    // """
    if (event->type() == QEvent::Show || event->type() == QEvent::Paint) {
        QToolButton* button = qobject_cast<QToolButton*>(object);
        if (button && !button->actions().isEmpty()) {
            QAction* action = button->actions().first();
            QString toolTip = KGlobal::locale()->removeAcceleratorMarker(action->toolTip());
            // Filtering message requested by translators (scripting).
            button->setToolTip(i18nc("@info:tooltip of custom toolbar button", "%1", toolTip));
        }
    }

    return false;
}
开发者ID:fluxer,项目名称:kde-extraapps,代码行数:47,代码来源:fullscreenbar.cpp

示例15: addOpenInTabs

void KBookmarkMenu::addOpenInTabs()
{
    if (!m_pOwner || !m_pOwner->supportsTabs() || !KAuthorized::authorizeKAction(QStringLiteral("bookmarks"))) {
        return;
    }

    QString title = tr("Open Folder in Tabs");

    QAction *paOpenFolderInTabs = new QAction(title, this);
    paOpenFolderInTabs->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
    paOpenFolderInTabs->setToolTip(tr("Open all bookmarks in this folder as a new tab."));
    paOpenFolderInTabs->setStatusTip(paOpenFolderInTabs->toolTip());
    connect(paOpenFolderInTabs, &QAction::triggered, this, &KBookmarkMenu::slotOpenFolderInTabs);

    m_parentMenu->addAction(paOpenFolderInTabs);
    m_actions.append(paOpenFolderInTabs);
}
开发者ID:KDE,项目名称:kbookmarks,代码行数:17,代码来源:kbookmarkmenu.cpp


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