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


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

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


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

示例1: createThemeMenu

void NMainMenuBar::createThemeMenu(QMenu *parentMenu) {
    QMenu *menu = parentMenu->addMenu(tr("Theme"));
    QStringList list = global.getThemeNames();
    QFont f = global.getGuiFont(QFont());

    global.settings->beginGroup(INI_GROUP_APPEARANCE);
    QString userTheme = global.settings->value("themeName", DEFAULT_THEME_NAME).toString();
    global.settings->endGroup();


    // Setup themes (we expect to find the DEFAULT_THEME_NAME theme as first one)
    for (int i = 0; i < list.size(); i++) {
        QString themeName(list[i]);
        if ((i == 0) && (QString::compare(themeName, DEFAULT_THEME_NAME, Qt::CaseInsensitive) != 0)) {
            QLOG_ERROR() << "First theme is expected to be " << DEFAULT_THEME_NAME;
        }


        QAction *themeAction = new QAction(themeName, this);
        themeAction->setData(themeName);
        themeAction->setCheckable(true);
        themeAction->setFont(f);
        connect(themeAction, SIGNAL(triggered()), parent, SLOT(reloadIcons()));
        if (themeName == userTheme) {
            themeAction->setChecked(true);
        }
        themeActions.append(themeAction);
    }
    menu->addActions(themeActions);
    menu->setFont(f);
}
开发者ID:jeffkowalski,项目名称:Nixnote2,代码行数:31,代码来源:nmainmenubar.cpp

示例2: createPageAction

/** Creates a new action associated with a config page. */
QAction* ApplicationWindow::createPageAction(QIcon img, QString text, QActionGroup *group)
{
    QAction *action = new QAction(img, text, group);
    action->setCheckable(true);
    action->setFont(FONT);
    return action;
}
开发者ID:autoscatto,项目名称:retroshare,代码行数:8,代码来源:ApplicationWindow.cpp

示例3: toQAction

QAction* ActionResource::toQAction() const {
    Log log( Log::LT_TRACE, Log::MOD_MAIN, "QAction* ActionResource::toQAction() const" );

    if( !( m_Type == AT_ITEM || m_Type == AT_SEPARATOR ) ) {
        return NULL;
    };

    log.write( Log::LT_TRACE, "Produce item %s", getText() );
    QAction* act = new QAction( getText(), NULL );
    act->setAutoRepeat( getAutoRepeat() );
    act->setCheckable( getCheckable() );
    act->setChecked( getChecked() );
    act->setData( getData() );
    act->setFont( getFont() );
    act->setIcon( getIcon() );
    act->setIconVisibleInMenu( getIconVisibleInMenu() );
    act->setMenuRole( getMenuRole() );
    act->setSeparator( m_Type == AT_SEPARATOR );
    act->setShortcut( getShortcut() );
    act->setShortcutContext( getShortcutContext() );
    act->setStatusTip( getStatusTip() );
    act->setToolTip( getTooltip() );
    act->setVisible( getVisible() );
    act->setWhatsThis( getWhatsThis() );

    return act;
};
开发者ID:sunepoulsen,项目名称:toolkit,代码行数:27,代码来源:actionresource.cpp

示例4: on_list_customContextMenuRequested

void Pane::on_list_customContextMenuRequested(const QPoint &pos) {
  File_info file = file_list_model.get_file_info(ui->list->indexAt(pos));
  App_info_list apps = main_window->get_apps(file.mime_type);
  QMenu* menu = new QMenu(this);
  if (file.is_folder()) {
    menu->addAction(tr("Browse"))->setEnabled(false);
  }
  if (file.is_file) {
    menu->addAction(main_window->get_ui()->action_view);
    menu->addAction(main_window->get_ui()->action_edit);
  }
  if (file.is_executable) {
    menu->addAction(main_window->get_ui()->action_execute);
  }
  if (menu->actions().count() > 0) menu->addSeparator();

  foreach(App_info app, apps) {
    QAction* a = menu->addAction(tr("Open with %1 (%2)").arg(app.name()).arg(app.command()), this, SLOT(action_launch_triggered()));
    QVariantList data;
    data << QVariant::fromValue(app) << QVariant::fromValue(file);
    a->setData(data);
    if (app == apps.default_app) {
      QFont f = a->font();
      f.setBold(true);
      a->setFont(f);
    }
  }
开发者ID:CSRedRat,项目名称:ridual,代码行数:27,代码来源:Pane.cpp

示例5: createContextMenu

void SGSelectionTool::createContextMenu(const QList<QSGItem *> &items, QPoint pos)
{
    QMenu contextMenu;
    connect(&contextMenu, SIGNAL(hovered(QAction*)),
            this, SLOT(contextMenuElementHovered(QAction*)));

    const QList<QSGItem*> selectedItems = inspector()->selectedItems();
    int shortcutKey = Qt::Key_1;

    foreach (QSGItem *item, items) {
        const QString title = inspector()->titleForItem(item);
        QAction *elementAction = contextMenu.addAction(title);
        elementAction->setData(QVariant::fromValue(item));

        connect(elementAction, SIGNAL(triggered()), this, SLOT(contextMenuElementSelected()));

        if (selectedItems.contains(item)) {
            QFont font = elementAction->font();
            font.setBold(true);
            elementAction->setFont(font);
        }

        if (shortcutKey <= Qt::Key_9) {
            elementAction->setShortcut(QKeySequence(shortcutKey));
            shortcutKey++;
        }
    }

    contextMenu.exec(pos);
}
开发者ID:yinyunqiao,项目名称:qtdeclarative,代码行数:30,代码来源:sgselectiontool.cpp

示例6: contextMenuEvent

void SessionListWidget::contextMenuEvent(QContextMenuEvent *event)
{
   QModelIndex index = indexAt(event->pos());
   if (index.isValid()) {
      JobDefinition &job = sessions[index.row()];
      qDebug() << job;

      QMenu *menu = new QMenu(this);
      QAction *action;
      switch(job.status) {
         case JobDefinition::QUEUED: {
            action = new QAction("Delete session", this);
            action->setData(qVariantFromValue(&job));
            connect(action, SIGNAL(triggered()), this, SLOT(removeSessionSlot()));
            menu->addAction(action);

            break;
         }

         case JobDefinition::HELD: {
            action = new QAction("Resume session", this);
            action->setData(qVariantFromValue(&job));
            connect(action, SIGNAL(triggered()), this, SLOT(releaseSessionSlot()));
            menu->addAction(action);

            action = new QAction("Delete session", this);
            action->setData(qVariantFromValue(&job));
            connect(action, SIGNAL(triggered()), this, SLOT(removeSessionSlot()));
            menu->addAction(action);

            break;
         }

         case JobDefinition::RUNNING: {
            action = new QAction("View session", this);
            QFont f = action->font();
            f.setBold(true);
            action->setFont(f);
            action->setData(qVariantFromValue(&job));
            connect(action, SIGNAL(triggered()), this, SLOT(viewSessionSlot()));
            menu->addAction(action);

            action = new QAction("Delete session", this);
            action->setData(qVariantFromValue(&job));
            connect(action, SIGNAL(triggered()), this, SLOT(removeSessionSlot()));
            menu->addAction(action);

            break;
         }

         case JobDefinition::FINISHED: {
            menu->addAction("Resume session [TODO]");
            break;
         }
      }

      menu->exec(QCursor::pos());
   }
}
开发者ID:eduffy,项目名称:hpcvmmon,代码行数:59,代码来源:SessionListWidget.cpp

示例7: italicTextItem

static QAction* italicTextItem(const QString& s)
{
    QAction* act = new QAction(s, NULL);
    QFont italicFont = act->font();
    italicFont.setItalic(true);
    act->setFont(italicFont);

    return act;
}
开发者ID:sanyaade-embedded-systems,项目名称:STA,代码行数:9,代码来源:qtselectionpopup.cpp

示例8: boldTextItem

static QAction* boldTextItem(const QString& s)
{
    QAction* act = new QAction(s, NULL);
    QFont boldFont = act->font();
    boldFont.setBold(true);
    act->setFont(boldFont);

    return act;
}
开发者ID:sanyaade-embedded-systems,项目名称:STA,代码行数:9,代码来源:qtselectionpopup.cpp

示例9: addGroupMarkToMenu

// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
// helpers
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
void FileSystemBrowser::addGroupMarkToMenu( QString text )
{
    QFont   font;
            font.setBold( true );
            font.setStyle( QFont::StyleOblique );

    QAction* action = 0;

    action = _fileBrowserMenu.addAction( QString("~~~~~ %1 ~~~~~").arg(text) );
    action->setFont( font );
}
开发者ID:nic0lae,项目名称:freebsddistro,代码行数:14,代码来源:FileSystemBrowser.cpp

示例10: QWidget

/** Constructor */
FeedReaderFeedItem::FeedReaderFeedItem(RsFeedReader *feedReader, FeedReaderNotify *notify, FeedHolder *parent, const FeedInfo &feedInfo, const FeedMsgInfo &msgInfo)
    : QWidget(NULL), mFeedReader(feedReader), mNotify(notify), mParent(parent), ui(new Ui::FeedReaderFeedItem)
{
    /* Invoke the Qt Designer generated object setup routine */
    ui->setupUi(this);

    setAttribute(Qt::WA_DeleteOnClose, true);

    connect(ui->expandButton, SIGNAL(clicked(void)), this, SLOT(toggle(void)));
    connect(ui->clearButton, SIGNAL(clicked(void)), this, SLOT(removeItem(void)));
    connect(ui->readAndClearButton, SIGNAL(clicked()), this, SLOT(readAndClearItem()));
    connect(ui->linkButton, SIGNAL(clicked()), this, SLOT(openLink()));

    connect(mNotify, SIGNAL(msgChanged(QString,QString,int)), this, SLOT(msgChanged(QString,QString,int)), Qt::QueuedConnection);

    ui->expandFrame->hide();

    mFeedId = feedInfo.feedId;
    mMsgId = msgInfo.msgId;

    if (feedInfo.icon.empty()) {
        ui->feedIconLabel->hide();
    } else {
        /* use icon from feed */
        QPixmap pixmap;
        if (pixmap.loadFromData(QByteArray::fromBase64(feedInfo.icon.c_str()))) {
            ui->feedIconLabel->setPixmap(pixmap.scaled(16, 16, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
        } else {
            ui->feedIconLabel->hide();
        }
    }

    ui->titleLabel->setText(QString::fromUtf8(feedInfo.name.c_str()));
    ui->msgTitleLabel->setText(QString::fromUtf8(msgInfo.title.c_str()));
    ui->descriptionLabel->setText(QString::fromUtf8((msgInfo.descriptionTransformed.empty() ? msgInfo.description : msgInfo.descriptionTransformed).c_str()));

    ui->dateTimeLabel->setText(DateTime::formatLongDateTime(msgInfo.pubDate));

    /* build menu for link button */
    mLink = QString::fromUtf8(msgInfo.link.c_str());
    if (mLink.isEmpty()) {
        ui->linkButton->setEnabled(false);
    } else {
        QMenu *menu = new QMenu(this);
        QAction *action = menu->addAction(tr("Open link in browser"), this, SLOT(openLink()));
        menu->addAction(tr("Copy link to clipboard"), this, SLOT(copyLink()));

        QFont font = action->font();
        font.setBold(true);
        action->setFont(font);

        ui->linkButton->setMenu(menu);
    }
}
开发者ID:RedCraig,项目名称:retroshare,代码行数:55,代码来源:FeedReaderFeedItem.cpp

示例11: markCurrent

void Favorites::markCurrent()
{
    for (int n = FIRST_MENU_ENTRY; n < _menu->actions().count(); n++)
    {
        QAction * a = _menu->actions()[n];
        QString file = a->data().toString();
        QFont f = a->font();

        if (file == current_file)
        {
            f.setBold(true);
            a->setFont( f );
        }
        else
        {
            f.setBold(false);
            a->setFont( f );
        }
    }
}
开发者ID:AlexRu,项目名称:rosa-media-player,代码行数:20,代码来源:favorites.cpp

示例12: QAction

QAction * QMenuViewPrivate::makeAction(const QModelIndex &index)
{
	QIcon icon = qvariant_cast<QIcon>(index.data(Qt::DecorationRole));
	QAction * action = new QAction(icon, index.data().toString(), this);
	action->setEnabled(index.flags().testFlag(Qt::ItemIsEnabled));
	// improvements for Qlipper (petr vanek <[email protected]>
	action->setFont(qvariant_cast<QFont>(index.data(Qt::FontRole)));
	action->setToolTip(index.data(Qt::ToolTipRole).toString());
	// end of qlipper improvements
	QVariant v;
	v.setValue(index);
	action->setData(v);

	return action;
}
开发者ID:ianorlin,项目名称:qlipper,代码行数:15,代码来源:qmenuview.cpp

示例13: addSortAction

void NMainMenuBar::addSortAction(QMenu *menu, QActionGroup *menuActionGroup, const QFont &f, QString name,
                                 QString code) {
    QString currentSortOrder = global.getSortOrder();

    QAction *action = new QAction(name, this);
    action->setData(code);
    action->setCheckable(true);
    if (QString::compare(code, currentSortOrder) == 0) {
        action->setChecked(true);
    }

    action->setFont(f);
    menuActionGroup->addAction(action);
    connect(action, SIGNAL(triggered()), this, SLOT(onSortMenuTriggered()));
    menu->addAction(action);
}
开发者ID:jeffkowalski,项目名称:Nixnote2,代码行数:16,代码来源:nmainmenubar.cpp

示例14: qDebug

void
ComboBox::addItemNew()
{
    if (_cascading) {
        qDebug() << "ComboBox::addItemNew unsupported when in cascading mode";

        return;
    }
    QAction* action =  new QAction(this);
    action->setText( QString::fromUtf8("New") );
    action->setData( QString::fromUtf8("New") );
    QFont f = QFont(appFont, appFontSize);
    f.setItalic(true);
    action->setFont(f);
    addActionPrivate(action);
}
开发者ID:Kthulhu,项目名称:Natron,代码行数:16,代码来源:ComboBox.cpp

示例15: populateContextMenu

void Speller::populateContextMenu(QMenu* menu, const QWebHitTestResult &hitTest)
{
    m_element = hitTest.element();

    if (!m_enabled || m_element.isNull() ||
            m_element.attribute(QLatin1String("type")) == QLatin1String("password")) {
        return;
    }

    const QString text = m_element.evaluateJavaScript("this.value").toString();
    const int pos = m_element.evaluateJavaScript("this.selectionStart").toInt() + 1;

    QTextBoundaryFinder finder =  QTextBoundaryFinder(QTextBoundaryFinder::Word, text);
    finder.setPosition(pos);
    m_startPos = finder.toPreviousBoundary();
    m_endPos = finder.toNextBoundary();

    const QString &word = text.mid(m_startPos, m_endPos - m_startPos).trimmed();

    if (!isValidWord(word) || !isMisspelled(word)) {
        return;
    }

    const int limit = 6;
    QStringList suggests = suggest(word);
    int count = suggests.count() > limit ? limit : suggests.count();

    QFont boldFont = menu->font();
    boldFont.setBold(true);

    for (int i = 0; i < count; ++i) {
        QAction* act = menu->addAction(suggests.at(i), this, SLOT(replaceWord()));
        act->setData(suggests.at(i));
        act->setFont(boldFont);
    }

    if (count == 0) {
        menu->addAction(tr("No suggestions"))->setEnabled(false);
    }

    menu->addAction(tr("Add to dictionary"), this, SLOT(addToDictionary()))->setData(word);
    menu->addSeparator();
}
开发者ID:Y-H,项目名称:qupzilla,代码行数:43,代码来源:speller.cpp


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