本文整理汇总了C++中QProgressBar::setStyleSheet方法的典型用法代码示例。如果您正苦于以下问题:C++ QProgressBar::setStyleSheet方法的具体用法?C++ QProgressBar::setStyleSheet怎么用?C++ QProgressBar::setStyleSheet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QProgressBar
的用法示例。
在下文中一共展示了QProgressBar::setStyleSheet方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateRangeMeter
QProgressBar* USNavigation::CreateRangeMeter(int i)
{
mitk::DataNode::Pointer zone = m_Zones.at(i);
float zoneColor[3];
bool success = m_Zones.at(i)->GetColor(zoneColor);
QString zoneColorString = "#555555";
if (success)
{
QString zoneColorString = QString("#%1%2%3").arg(static_cast<unsigned int>(zoneColor[0]*255), 2, 16, QChar('0'))
.arg(static_cast<unsigned int>(zoneColor[1]*255), 2, 16, QChar('0')).arg(static_cast<unsigned int>(zoneColor[2]*255), 2, 16, QChar('0'));
}
QProgressBar* meter = new QProgressBar();
meter->setMinimum(0);
meter->setMaximum(100);
meter->setValue(0);
QString zoneName = zone->GetName().c_str();
meter->setFormat(zoneName + ": No Data");
QString style = m_RangeMeterStyle;
style = style.replace("#StartColor#", zoneColorString);
style = style.replace("#StopColor#", zoneColorString);
meter->setStyleSheet(style);
meter->setVisible(true);
return meter;
}
示例2: execFinished
ProgressUI::ProgressUI(QWidget *parent)
: THWidgetBase(parent)
{
timerId = -1;
gradient = 0;
hideTitleBar();
setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::Tool);
setWindowModality(Qt::ApplicationModal);
QVBoxLayout *v = new QVBoxLayout(this);
v->setContentsMargins(5, 5, 5, 5);
v->setSpacing(0);
lbl = new QLabel(this);
lbl->setStyleSheet(QStringLiteral("font-family:΢ÈíÑźÚ;font:12px;color:white;"));
QProgressBar *pbar = new QProgressBar(this);
pbar->setRange(0, 100);
pbar->setValue(0);
pbar->setFixedSize(260, 12);
QFile file;
file.setFileName(":res/css/progressbar.css");
if (file.open(QIODevice::ReadOnly))
{
QByteArray ba = file.readAll();
pbar->setStyleSheet(QTextCodec::codecForLocale()->toUnicode(ba));
}
file.close();
v->addWidget(lbl, 1, Qt::AlignCenter);
v->addWidget(pbar, 1, Qt::AlignCenter);
setFixedSize(280, 50);
connect(this, &ProgressUI::setValue, pbar, [=] (int value) {
pbar->setValue(value);
if (pbar->value() >= 100)
{
lbl->setText(QStringLiteral("Íê³É"));
emit execFinished();
QTimer::singleShot(1000, this, [=] () {
disconnect(this, 0, 0, 0);
this->close();
this->deleteLater();
});
}
});
timerId = startTimer(60/*, Qt::VeryCoarseTimer*/);
}
示例3: UpdateMeters
void USNavigation::UpdateMeters()
{
// Get NeedlePosition
mitk::NavigationData::Pointer needle = this->m_Tracker->GetOutput(0);
if (! needle->IsDataValid()) return;
mitk::Point3D needlePosition = needle->GetPosition();
// Update each meter
for (int i = 0; i < m_Zones.size(); i++)
{
mitk::Point3D zoneOrigin = m_Zones.at(i)->GetData()->GetGeometry()->GetOrigin();
// calculate absolute distance
mitk::ScalarType distance = sqrt( pow(zoneOrigin[0] - needlePosition[0], 2) + pow(zoneOrigin[1] - needlePosition[1], 2) + pow(zoneOrigin[2] - needlePosition[2], 2) );
// Subtract zone size
float zoneSize;
m_Zones.at(i)->GetFloatProperty("zone.size", zoneSize);
distance = distance - zoneSize;
// Prepare new Style
float zoneColor[3];
m_Zones.at(i)->GetColor(zoneColor);
QString zoneColorString = QString("#%1%2%3").arg(static_cast<unsigned int>(zoneColor[0]*255), 2, 16, QChar('0'))
.arg(static_cast<unsigned int>(zoneColor[1]*255), 2, 16, QChar('0')).arg(static_cast<unsigned int>(zoneColor[2]*255), 2, 16, QChar('0'));
QString style = m_RangeMeterStyle;
QString text = m_Zones.at(i)->GetName().c_str();
int value = 0;
// There Are now four possible Outcomes
// 1) Needle is inside zone (bad news)
if (distance < 0)
{
style = style.replace("#StartColor#", "red");
style = style.replace("#StopColor#", "red");
text = text + ": VIOLATED";
value = 100;
} // 2) Needle is close to Zone
else if (distance < WARNRANGE)
{
style = style.replace("#StartColor#", zoneColorString);
style = style.replace("#StopColor#", "red");
text = text + ": " + QString::number(distance) + " mm";
value = 100 - 100 * ((float) distance / (float )MAXRANGE);
} // 3) Needle is away from zone
else if (distance < MAXRANGE)
{
style = style.replace("#StartColor#", zoneColorString);
style = style.replace("#StopColor#", zoneColorString);
text = text + ": " + QString::number(distance) + " mm";
value = 100 - 100 * ((float) distance / (float )MAXRANGE);
} // 4) Needle is far away from zone
else
{
style = style.replace("#StartColor#", zoneColorString);
style = style.replace("#StopColor#", zoneColorString);
text = text + ": " + QString::number(distance) + " mm";
value = 0;
}
QProgressBar * meter = this->m_RangeMeters.at(i);
meter->setStyleSheet(style);
meter->setFormat(text);
meter->setValue(value);
}
}