本文整理汇总了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);
}
示例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);
}
示例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;
}
示例4: toolTip
QString QActionProto::toolTip() const
{
QAction *item = qscriptvalue_cast<QAction*>(thisObject());
if (item)
return item->toolTip();
return QString();
}
示例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);
}
示例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));
}
示例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);
}
}
}
}
示例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()));
}
}
示例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);
}
示例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;
}
示例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;
}
示例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 );
}
}
示例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;
}
示例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;
}
示例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);
}