本文整理汇总了C++中QColor::setNamedColor方法的典型用法代码示例。如果您正苦于以下问题:C++ QColor::setNamedColor方法的具体用法?C++ QColor::setNamedColor怎么用?C++ QColor::setNamedColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QColor
的用法示例。
在下文中一共展示了QColor::setNamedColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseEntityDefinition
void EntityIdentifier::parseEntityDefinition(JSONObject *entity,
QString const &category,
QColor catcolor, int packID) {
QString id;
if (entity->has("id"))
id = entity->at("id")->asString();
else
id = "Unknown";
if (entity->has("catcolor")) {
QString colorname = entity->at("catcolor")->asString();
catcolor.setNamedColor(colorname);
assert(catcolor.isValid());
}
QColor color;
if (entity->has("color")) {
QString colorname = entity->at("color")->asString();
color.setNamedColor(colorname);
assert(color.isValid());
} else { // use hashed by name instead
quint32 hue = qHash(id);
color.setHsv(hue % 360, 255, 255);
}
QString name = id;
if (entity->has("name")) {
name = entity->at("name")->asString();
}
// enter entity into manager
TentityMap& map = getMapForPackID(packID);
map.insert(id, EntityInfo(name, category, catcolor, color));
}
示例2: drawPort
void CurveLine::drawPort(QPainter *painter, int portNumber)
{
if ((portNumber == 0) || (portNumber == mEdge->line().count() - 1)) {
LineHandler::drawPort(painter, portNumber);
return;
}
QPen pen;
pen.setCapStyle(Qt::RoundCap);
QColor color;
QPointF p1(-0.25, 0);
QPointF p2(0.25, 0);
color.setNamedColor("#ffcc66");
pen.setWidth(12);
pen.setColor(color);
painter->setPen(pen);
painter->drawLine(p1, p2);
color.setNamedColor("#ff6666");
pen.setWidth(3);
pen.setColor(color);
painter->setPen(pen);
painter->drawLine(p1, p2);
}
示例3: GetCurBtnColor
QColor PrefDialog::GetCurBtnColor(const QPushButton* btn)
{
QColor color;
if (mSettings != NULL)
{
if (btn == mRowHColorBgBtn)
{
color.setNamedColor(mSettings->mRowHColorBg);
}
else
{
color.setNamedColor(mSettings->mRowHColorFg);
}
}
if (mSettings == NULL || !color.isValid())
{
if (btn == mRowHColorBgBtn)
{
color = QApplication::palette().color(QPalette::Active, QPalette::Button);
}
else
{
color = QApplication::palette().color(QPalette::Active, QPalette::ButtonText);
}
}
return color;
}
示例4:
void SyntaxHighligther::loadConfig<None>() {
QColor textColor;
QColor bgColor;
textColor.setNamedColor("#aaaaaa");
bgColor.setNamedColor("#4d4d4d");
defaultFormat_.setBackground(bgColor);
defaultFormat_.setForeground(textColor);
}
示例5: decorateBrowser
void ConfigurationManager::decorateBrowser(ClipboardBrowser *c) const
{
QFont font;
QPalette p;
QColor color;
/* fonts */
font.fromString( ui->pushButtonFont->property("VALUE").toString() );
c->setFont(font);
/* scrollbars */
Qt::ScrollBarPolicy scrollbarPolicy = m_theme["show_scrollbars"].value().toBool()
? Qt::ScrollBarAsNeeded : Qt::ScrollBarAlwaysOff;
c->setVerticalScrollBarPolicy(scrollbarPolicy);
c->setHorizontalScrollBarPolicy(scrollbarPolicy);
/* colors */
p = c->palette();
color.setNamedColor( m_theme["bg"].value().toString() );
p.setBrush(QPalette::Base, color);
color.setNamedColor( m_theme["fg"].value().toString() );
p.setBrush(QPalette::Text, color);
color.setNamedColor( m_theme["alt_bg"].value().toString() );
p.setBrush(QPalette::AlternateBase, color);
color.setNamedColor( m_theme["sel_bg"].value().toString() );
p.setBrush(QPalette::Highlight, color);
color.setNamedColor( m_theme["sel_fg"].value().toString() );
p.setBrush(QPalette::HighlightedText, color);
c->setPalette(p);
/* search style */
ItemDelegate *d = static_cast<ItemDelegate *>( c->itemDelegate() );
font.fromString( m_theme["find_font"].value().toString() );
color.setNamedColor( m_theme["find_bg"].value().toString() );
p.setColor(QPalette::Base, color);
color.setNamedColor( m_theme["find_fg"].value().toString() );
p.setColor(QPalette::Text, color);
d->setSearchStyle(font, p);
/* editor style */
d->setSearchStyle(font, p);
font.fromString( m_theme["edit_font"].value().toString() );
color.setNamedColor( m_theme["edit_bg"].value().toString() );
p.setColor(QPalette::Base, color);
color.setNamedColor( m_theme["edit_fg"].value().toString() );
p.setColor(QPalette::Text, color);
d->setEditorStyle(font, p);
/* number style */
d->setShowNumber(m_theme["show_number"].value().toBool());
font.fromString( m_theme["num_font"].value().toString() );
color.setNamedColor( m_theme["num_fg"].value().toString() );
p.setColor(QPalette::Text, color);
d->setNumberStyle(font, p);
c->redraw();
}
示例6: expected
void tst_QColor::setallowX11ColorNames()
{
#if defined(Q_OS_IRIX)
QSKIP("This fails due to the gamma settings in the SGI X server", SkipAll);
#else
RGBData x11RgbTbl[] = {
// a few standard X11 color names
{ "DodgerBlue1", qRgb(30, 144, 255) },
{ "DodgerBlue2", qRgb(28, 134, 238) },
{ "DodgerBlue3", qRgb(24, 116, 205) },
{ "DodgerBlue4", qRgb(16, 78, 139) },
{ "SteelBlue1", qRgb(99, 184, 255) },
{ "SteelBlue2", qRgb(92, 172, 238) },
{ "SteelBlue3", qRgb(79, 148, 205) },
{ "SteelBlue4", qRgb(54, 100, 139) },
{ "DeepSkyBlue1", qRgb(0, 191, 255) },
{ "DeepSkyBlue2", qRgb(0, 178, 238) },
{ "DeepSkyBlue3", qRgb(0, 154, 205) },
{ "DeepSkyBlue4", qRgb(0, 104, 139) },
{ "SkyBlue1", qRgb(135, 206, 255) },
{ "SkyBlue2", qRgb(126, 192, 238) },
{ "SkyBlue3", qRgb(108, 166, 205) },
{ "SkyBlue4", qRgb(74, 112, 139) }
};
static const int x11RgbTblSize = sizeof(x11RgbTbl) / sizeof(RGBData);
// X11 color names should not work by default
QVERIFY(!QColor::allowX11ColorNames());
for (int i = 0; i < x11RgbTblSize; ++i) {
QString colorName = QLatin1String(x11RgbTbl[i].name);
QColor color;
color.setNamedColor(colorName);
QVERIFY(!color.isValid());
}
// enable X11 color names
QColor::setAllowX11ColorNames(true);
QVERIFY(QColor::allowX11ColorNames());
for (int i = 0; i < x11RgbTblSize; ++i) {
QString colorName = QLatin1String(x11RgbTbl[i].name);
QColor color;
color.setNamedColor(colorName);
QColor expected(x11RgbTbl[i].value);
QCOMPARE(color, expected);
}
// should be able to turn off X11 color names
QColor::setAllowX11ColorNames(false);
QVERIFY(!QColor::allowX11ColorNames());
for (int i = 0; i < x11RgbTblSize; ++i) {
QString colorName = QLatin1String(x11RgbTbl[i].name);
QColor color;
color.setNamedColor(colorName);
QVERIFY(!color.isValid());
}
#endif // Q_OS_IRIX
}
示例7: setLayout
ParConfWidget::ParConfWidget(QChar parName, bool withAnimateButton, bool withKeepTracksButton) : QGroupBox(), treeCreator(NORMAL_EXPR)
{
setTitle(tr("Adjustments for ") + parName + " :");
keepTracksButtonAvailable = withKeepTracksButton;
defaultRange.start = 0;
defaultRange.step = 1;
defaultRange.end = 0.5;
keepTracks = NULL;
QHBoxLayout *widgetsLayout = new QHBoxLayout;
widgetsLayout->setSpacing(3);
addConfWidgets(widgetsLayout);
startTree = endTree = stepTree = NULL;
kState = valid = isStepGood = isEndGood = isStartGood = false;
QColor color;
color.setNamedColor(VALID_COLOR);
validPalette.setColor(QPalette::Base, color);
validPalette.setColor(QPalette::Text, Qt::black);
color.setNamedColor(INVALID_COLOR);
invalidPalette.setColor(QPalette::Base, color);
invalidPalette.setColor(QPalette::Text, Qt::black);
if(withAnimateButton)
{
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->setSpacing(3);
mainLayout->addLayout(widgetsLayout);
QHBoxLayout *animateLayout = new QHBoxLayout;
animate = new QCheckBox(tr("Animate"));
connect(animate, SIGNAL(toggled(bool)), this, SIGNAL(animateToggled(bool)));
animateLayout->addWidget(animate);
if(withKeepTracksButton)
{
keepTracks = new QCheckBox(tr("Keep tracks"));
animateLayout->addWidget(keepTracks);
treeCreator.allow_k(true);
}
animateLayout->addStretch();
mainLayout->addLayout(animateLayout);
setLayout(mainLayout);
}
else setLayout(widgetsLayout);
示例8: parseEntityDefinition
void EntityIdentifier::parseEntityDefinition(JSONObject *entity,
QString const &category,
QColor catcolor, int packID) {
QString id("unknown");
if (entity->has("id"))
id = entity->at("id")->asString().toLower();
if (entity->has("catcolor")) {
QString colorname = entity->at("catcolor")->asString();
catcolor.setNamedColor(colorname);
assert(catcolor.isValid());
}
QColor color;
if (entity->has("color")) {
QString colorname = entity->at("color")->asString();
color.setNamedColor(colorname);
assert(color.isValid());
} else { // use hashed by name instead
quint32 hue = qHash(id);
color.setHsv(hue % 360, 255, 255);
}
QString name;
if (entity->has("name")) {
// use provided name
name = entity->at("name")->asString();
} else {
// or try to build name automatically
// split at underscores
QStringList tokens = id.toLower().replace('_',' ').split(" ");
// make first character uppercase
for (QList<QString>::iterator tokItr = tokens.begin(); tokItr != tokens.end(); ++tokItr) {
(*tokItr) = (*tokItr).at(0).toUpper() + (*tokItr).mid(1);
}
name = tokens.join(" ");
}
// enter entity into manager
TentityMap& map = getMapForPackID(packID);
map.insert(id, EntityInfo(name, category, catcolor, color));
// add duplicates: when new 1.11+ or 1.13+ id definitions are available
// legacy id is stored in own definition element (duplicates automatically)
if (entity->has("idlist")) {
JSONArray *idlist = dynamic_cast<JSONArray *>(entity->at("idlist"));
int len = idlist->length();
for (int j = 0; j < len; j++) {
QString idl = entity->at("idlist")->at(j)->asString().toLower();
map.insert(idl, EntityInfo(name, category, catcolor, color));
}
}
}
示例9: on_pushButton_clicked
// Проверка скобок
void MainWindow::on_pushButton_clicked()
{
SET_CODEC;
StackType type;
if (ui->radioButton_3->isChecked())
type = Array;
else
type = List;
QString text = ui->lineEdit->text().trimmed();
if (text.length() == 0) {
Error error((QString) "Пустой ввод!");
error.Show();
return;
}
if (!(text.contains('(') || text.contains(')') || text.contains('[') || text.contains(']')
|| text.contains('{') || text.contains('}'))) {
Error error((QString) "Введенное выражение не содержит скобок!");
error.Show();
return;
}
ui->textEdit->clear();
// Проверка на правильность скобок
bool result;
try {
result = isRightBrackets(text, type);
// Вывод результата проверки
QColor color;
QPalette::ColorRole cr;
QPalette palette;
if (result) {
ui->label_2->setText("Скобки расставлены верно!");
color.setNamedColor("green");
} else {
ui->label_2->setText("Скобки расставлены неверно!");
color.setNamedColor("red");
}
cr = QPalette::WindowText;
palette.setColor(cr, color);
ui->label_2->setPalette(palette);
} catch(Error err) {
this->Log((QString *) &(err.getErrorDescription()));
err.Show();
}
}
示例10: slotFindAll
void PMWindow::slotFindAll(){
if (!toolButton_ALL->isChecked()){
textEdit_CHAT->setExtraSelections(QList<QTextEdit::ExtraSelection>());
return;
}
QList<QTextEdit::ExtraSelection> extraSelections;
if (!lineEdit_FIND->text().isEmpty()) {
QTextEdit::ExtraSelection selection;
QColor color;
color.setNamedColor(WSGET(WS_CHAT_FIND_COLOR));
color.setAlpha(WIGET(WI_CHAT_FIND_COLOR_ALPHA));
selection.format.setBackground(color);
QTextCursor c = textEdit_CHAT->document()->find(lineEdit_FIND->text(), 0, 0);
while (!c.isNull()){
selection.cursor = c;
extraSelections.append(selection);
c = textEdit_CHAT->document()->find(lineEdit_FIND->text(), c, 0);
}
}
textEdit_CHAT->setExtraSelections(extraSelections);
}
示例11: getLightness
float Theme::getLightness(QString color) {
QColor c;
c.setNamedColor(color);
QColor converted = c.toHsv();
return converted.valueF();
}
示例12: getSaturation
float Theme::getSaturation(QString color) {
QColor c;
c.setNamedColor(color);
QColor converted = c.toHsv();
return converted.hsvSaturationF();
}
示例13: getHue
float Theme::getHue(QString color) {
QColor c;
c.setNamedColor(color);
QColor converted = c.toHsv();
return converted.hsvHueF();
}
示例14: paintCell
void toResultViewItem::paintCell(QPainter * p, const QColorGroup & cg, int column, int width, int align)
{
#if 0 // disabled, not overriding correct function anyhow
// null related background handling
QColorGroup colNull(cg);
if ((toConfigurationSingle::Instance().indicateEmpty() && text(column) == "{null}")
|| text(column).isNull())
{
QColor nullColor;
nullColor.setNamedColor(toConfigurationSingle::Instance().indicateEmptyColor());
colNull.setColor(QColorGroup::Base, nullColor);
}
toTreeWidgetItem::paintCell(p, colNull, column, width, align);
toResultView *view = dynamic_cast<toResultView *>(listView());
if (view && (itemBelow() == NULL || itemBelow()->itemBelow() == NULL))
view->addItem();
if (Gridlines)
{
p->setPen(Qt::gray);
p->drawLine(width - 1, 0, width - 1, height());
p->drawLine(0, height() - 1, width - 1, height() - 1);
}
#endif
}
示例15: tagColorChanged
void
TagColorEditor::itemChanged(QTableWidgetItem *item)
{
uchar *colors = Global::tagColors();
int row = item->row();
int colm = item->column();
if (colm == 0)
{
QColor clr;
clr.setNamedColor(item->data(Qt::DisplayRole).toString());
item->setData(Qt::DecorationRole, clr);
colors[4*(row+1)+0] = clr.red();
colors[4*(row+1)+1] = clr.green();
colors[4*(row+1)+2] = clr.blue();
}
else
{
double opv = item->data(Qt::DisplayRole).toDouble();
int op = opv*255;
op = qMin(op, 255);
colors[4*(row+1)+3] = op;
}
emit tagColorChanged();
}