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


C++ QLabel::foregroundRole方法代码示例

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


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

示例1: eventFilter

/*virtual*/
bool ChoiceFilter::eventFilter(QObject *obj, QEvent *event)
{
    QPalette palette;
    QLabel *label;

    if (event->type() == QEvent::Enter) {
        label = qobject_cast<QLabel*>(obj);
        palette = label->palette();
        this->usualColor = palette.color(QPalette::Text);
        palette.setColor(label->foregroundRole(), QColor(Qt::cyan));
        label->setPalette(palette);

        return true;
    }

    if (event->type() == QEvent::Leave) {
        label = qobject_cast<QLabel*>(obj);
        palette = label->palette();
        palette.setColor(label->foregroundRole(), this->usualColor);
        label->setPalette(palette);

        return true;
    }
    return false;
}
开发者ID:ivashchenko-leo,项目名称:TextQuest,代码行数:26,代码来源:choicefilter.cpp

示例2: contextMenuEvent

/**
 * Shows a context menu for the layer widget. Launched with a right click.
 */
void QG_LayerWidget::contextMenuEvent(QContextMenuEvent *e) {

    if (actionHandler) {
        QMenu* contextMenu = new QMenu(this);
        QLabel* caption = new QLabel(tr("Layer Menu"), this);
        QPalette palette;
        palette.setColor(caption->backgroundRole(), RS_Color(0,0,0));
        palette.setColor(caption->foregroundRole(), RS_Color(255,255,255));
        caption->setPalette(palette);
        caption->setAlignment( Qt::AlignCenter );
        contextMenu->addAction( tr("&Defreeze all Layers"), actionHandler,
                                 SLOT(slotLayersDefreezeAll()), 0);
        contextMenu->addAction( tr("&Freeze all Layers"), actionHandler,
                                 SLOT(slotLayersFreezeAll()), 0);
        contextMenu->addSeparator();
        contextMenu->addAction( tr("&Add Layer"), actionHandler,
                                 SLOT(slotLayersAdd()), 0);
        contextMenu->addAction( tr("&Remove Layer"), actionHandler,
                                 SLOT(slotLayersRemove()), 0);
        contextMenu->addAction( tr("Edit Layer &Attributes"), actionHandler,
                                 SLOT(slotLayersEdit()), 0);
        contextMenu->addAction( tr("Toggle Layer &Visibility"), actionHandler,
                                 SLOT(slotLayersToggleView()), 0);
        contextMenu->addAction( tr("Toggle Layer &Printing"), actionHandler,
                                 SLOT(slotLayersTogglePrint()), 0);
        contextMenu->addAction( tr("Toggle &Construction Layer"), actionHandler,
                                 SLOT(slotLayersToggleConstruction()), 0);
        contextMenu->exec(QCursor::pos());
        delete contextMenu;
    }

    e->accept();
}
开发者ID:Aly1029,项目名称:LibreCAD,代码行数:36,代码来源:qg_layerwidget.cpp

示例3: contextMenuEvent

/**
 * Shows a context menu for the block widget. Launched with a right click.
 */
void QG_BlockWidget::contextMenuEvent(QContextMenuEvent *e) {

    QMenu* contextMenu = new QMenu(this);
    QLabel* caption = new QLabel(tr("Block Menu"), this);
    QPalette palette;
    palette.setColor(caption->backgroundRole(), RS_Color(0,0,0));
    palette.setColor(caption->foregroundRole(), RS_Color(255,255,255));
    caption->setPalette(palette);
    caption->setAlignment( Qt::AlignCenter );
    contextMenu->addAction( tr("&Defreeze all Blocks"), actionHandler,
                             SLOT(slotBlocksDefreezeAll()), 0);
    contextMenu->addAction( tr("&Freeze all Blocks"), actionHandler,
                             SLOT(slotBlocksFreezeAll()), 0);
    contextMenu->addAction( tr("&Add Block"), actionHandler,
                             SLOT(slotBlocksAdd()), 0);
    contextMenu->addAction( tr("&Remove Block"), actionHandler,
                             SLOT(slotBlocksRemove()), 0);
    contextMenu->addAction( tr("&Rename Block"), actionHandler,
                             SLOT(slotBlocksAttributes()), 0);
    contextMenu->addAction( tr("&Edit Block"), actionHandler,
                             SLOT(slotBlocksEdit()), 0);
    contextMenu->addAction( tr("&Insert Block"), actionHandler,
                             SLOT(slotBlocksInsert()), 0);
    contextMenu->addAction( tr("&Toggle Visibility"), actionHandler,
                             SLOT(slotBlocksToggleView()), 0);
    contextMenu->addAction( tr("&Create New Block"), actionHandler,
                             SLOT(slotBlocksCreate()), 0);
    contextMenu->exec(QCursor::pos());
    delete contextMenu;

    e->accept();
}
开发者ID:RobertvonKnobloch,项目名称:LibreCAD,代码行数:35,代码来源:qg_blockwidget.cpp

示例4: addOptionalMessage

/** Add the optional message in a light yellow box to the layout
 *
 * @param mainLay :: layout
 */
void AlgorithmDialog::addOptionalMessage(QVBoxLayout *mainLay) {
  QLabel *inputMessage = new QLabel(this);
  inputMessage->setFrameStyle(QFrame::Panel | QFrame::Sunken);
  QPalette pal = inputMessage->palette();
  pal.setColor(inputMessage->backgroundRole(),
               QColor(255, 255, 224)); // Light yellow
  pal.setColor(inputMessage->foregroundRole(), Qt::black);
  inputMessage->setPalette(pal);
  inputMessage->setAutoFillBackground(true);
  inputMessage->setWordWrap(true);
  inputMessage->setAlignment(Qt::AlignJustify);
  inputMessage->setMargin(3);
  inputMessage->setText(getOptionalMessage());
  QHBoxLayout *msgArea = new QHBoxLayout;
  msgArea->addWidget(inputMessage);
  mainLay->addLayout(msgArea, 0);
}
开发者ID:DanNixon,项目名称:mantid,代码行数:21,代码来源:AlgorithmDialog.cpp

示例5: setLabelStatus

void CertificateDisplayDialog::setLabelStatus(QLabel& l, bool ok)
{
	QPalette palette;
	palette.setColor(l.foregroundRole(), ok ? QColor("#2A993B") : QColor("#810000"));
	l.setPalette(palette);
}
开发者ID:partition,项目名称:kadu,代码行数:6,代码来源:certificate-display-dialog.cpp


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