本文整理汇总了C++中QLabel::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ QLabel::clear方法的具体用法?C++ QLabel::clear怎么用?C++ QLabel::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLabel
的用法示例。
在下文中一共展示了QLabel::clear方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char ** argv) {
QApplication app{argc, argv};
QWidget w;
QFormLayout layout{&w};
QLineEdit address;
layout.addRow("Address to look up", &address);
QLabel result;
layout.addRow("Result", &result);
QPushButton lookup{"Lookup"};
layout.addRow(&lookup);
lookup.setDefault(true);
w.show();
IfLookup ifLookup;
QObject::connect(&lookup, &QPushButton::clicked, [&]{
result.clear();
ifLookup.lookup(address.text());
});
QObject::connect(&ifLookup, &IfLookup::hasResult, [&](IfLookup::Result r){
static const QMap<IfLookup::Result, QString> msgs = {
{ IfLookup::Local, "Local" }, { IfLookup::NonLocal, "Non-Local" },
{ IfLookup::TimedOut, "Timed Out" }, { IfLookup::Error, "Lookup Error" }
};
result.setText(msgs.value(r));
});
return app.exec();
}
示例2: clearButtonClicked
void BinCalcWidget::clearButtonClicked()
{
QLineEdit *lineEdit = findChild<QLineEdit *>();
if( lineEdit == 0 )
return;
QLabel *label = findChild<QLabel *>();
if( label == 0 )
return;
lineEdit->clear();
label->clear();
m_operator.clear();
m_value = 0;
}
示例3: updateCharts
void LapTimeComparisonDialog::updateCharts()
{
DriverData *driverData[4] = {0, 0, 0, 0};
QString driver;
for (int i = 0; i < 4; ++i)
{
int idx = eventData.getDriverId(getNumber(i));
if (idx > 0)
{
driver = eventData.getDriversData()[idx-1].getDriverName();
driverData[i] = &eventData.getDriversData()[idx-1];
// carIdx = (eventData.getDriversData()[idx-1].getNumber() > 13 ?
// eventData.getDriversData()[idx-1].getNumber() - 2 :
// eventData.getDriversData()[idx-1].getNumber() - 1) / 2;
QTableWidgetItem *item = ui->chartsTableWidget->item(0, i);
item->setText(driver);
item->setTextColor(ColorsManager::getInstance().getCarColor(driverData[i]->getNumber()));
// if (carIdx >= 0)
{
QLabel *lab = qobject_cast<QLabel*>(ui->chartsTableWidget->cellWidget(1, i));
if (!lab)
{
lab = new QLabel();
lab->setAlignment(Qt::AlignCenter);
lab->setPixmap(ImagesFactory::getInstance().getCarThumbnailsFactory().getCarThumbnail(driverData[i]->getNumber(), thumbnailsSize));//eventData.carImages[carIdx].scaledToWidth(120, Qt::SmoothTransformation));
ui->chartsTableWidget->setCellWidget(1, i, lab);
}
else
lab->setPixmap(ImagesFactory::getInstance().getCarThumbnailsFactory().getCarThumbnail(driverData[i]->getNumber(), thumbnailsSize));//eventData.carImages[carIdx].scaledToWidth(120, Qt::SmoothTransformation));
}
}
else
{
QTableWidgetItem *item = ui->chartsTableWidget->item(0, i);
item->setText("");
QLabel *lab = qobject_cast<QLabel*>(ui->chartsTableWidget->cellWidget(1, i));
if (lab)
lab->clear();
}
}
lapCompChart->setData(driverData);
lapCompChart->repaint();
}
示例4: updateTankReborn
void FormGame::updateTankReborn()
{
ITank* tank = (ITank*)sender();
int index = _tanks.indexOf(tank);
if(index > -1)
{
int index_of_player = _match_players.value(index);
QLabel* label = findChild<QLabel*>(QString("_l_time_to_reborn_%1").arg(index_of_player));
label->clear();
label->hide();
}
if(tank == _tank)
{
updateTankView();
}
}
示例5: QWidget
QWidget *AppAboutPage::createPage(QWidget *parent)
{
QWidget *w = new QWidget(parent);
QVBoxLayout *layout = new QVBoxLayout(w);
layout->setSpacing(0);
layout->setMargin(0);
// Splash label
QWidget *sw = new QWidget(w);
QHBoxLayout *swLayout = new QHBoxLayout(sw);
sw->setLayout(swLayout);
QLabel *splash = new QLabel(w);
splash->setPixmap(theme()->splashScreenPixmap(settings()->path(Core::ISettings::SplashScreen)));
splash->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
swLayout->addSpacerItem(new QSpacerItem(10, 10, QSizePolicy::Expanding));
swLayout->addWidget(splash);
swLayout->addSpacerItem(new QSpacerItem(10, 10, QSizePolicy::Expanding));
layout->addWidget(sw);
QFrame *line = new QFrame(w);
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
layout->addWidget(line);
layout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Fixed, QSizePolicy::Fixed));
// Welcome label
QLabel *label = new QLabel(w);
label->setWordWrap(true);
label->setOpenExternalLinks(true);
layout->addWidget(label);
layout->addSpacerItem(new QSpacerItem(20,20, QSizePolicy::Expanding, QSizePolicy::Expanding));
label->clear();
Utils::UpdateChecker *up = Core::ICore::instance()->updateChecker();
QString tmp = tkTr(Trans::Constants::APPLICATION_ABOUT_YEAR_1_WEB_2)
.arg(QDate::currentDate().year())
.arg(qApp->organizationDomain());
if (up->hasUpdate()) {
tmp.append(tkTr(Trans::Constants::UPDATE_AVAILABLE));
} else {
tmp.append(tkTr(Trans::Constants::VERSION_UPTODATE));
}
label->setText(tmp);
return w;
}
示例6: show
void LapTimeComparisonDialog::show(int currentCarId)
{
// if (comboBox[0]->itemText(1) == "")
// {
// comboBox[0]->addItems(SeasonData::getInstance().getDriversList());
// comboBox[1]->addItems(SeasonData::getInstance().getDriversList());
// comboBox[2]->addItems(SeasonData::getInstance().getDriversList());
// comboBox[3]->addItems(SeasonData::getInstance().getDriversList());
// }
setCurrentDriver(currentCarId);
for (int i = 0; i < 4; ++i)
{
QLabel *lab = qobject_cast<QLabel*>(ui->tableWidget->cellWidget(0, i+1));
if (lab)
lab->clear();
}
updateData();
updateCharts();
QDialog::show();
}
示例7: QWidget
QWidget *AppAboutPage::createPage(QWidget *parent)
{
QWidget *w = new QWidget(parent);
QVBoxLayout *layout = new QVBoxLayout(w);
layout->setSpacing(0);
layout->setMargin(0);
QLabel *label = new QLabel(w);
label->setWordWrap(true);
label->setOpenExternalLinks(true);
layout->addWidget(label);
layout->addSpacerItem(new QSpacerItem(20,20, QSizePolicy::Expanding, QSizePolicy::Expanding));
label->clear();
Utils::UpdateChecker *up = Core::ICore::instance()->updateChecker();
QString tmp = tr(ABOUT_TEXT).arg(qApp->applicationName(), qApp->organizationDomain()).arg(QDate::currentDate().year());
if (up->hasUpdate()) {
tmp.append("<br /><br />" + tkTr(Trans::Constants::UPDATE_AVAILABLE));
} else {
tmp.append("<br /><br />" + tkTr(Trans::Constants::VERSION_UPTODATE));
}
label->setText(tmp);
return w;
}
示例8: updateImages
/**
* 五组原图显示函数
*/
bool ImageViewer::updateImages()
{
if (!hasinitmodel)
return false;
QString tmpcamid;
bool ret = true;
QString tmpcamimgdir;
QLabel * tmpcamimg1 = NULL;
QLabel * tmpcamimg2 = NULL;
QLabel * tmpcamimg3 = NULL;
QLabel * tmpcamimg4 = NULL;
QLabel * tmpcamimg5 = NULL;
QLabel * tmpcamimg = NULL;
tmphasfc1 = false;
tmphasfc2 = false;
tmphasfc3 = false;
tmphasfc4 = false;
tmphasfc5 = false;
for (int i = 0; i < 5; i++)
{
switch (i)
{
case 0: tmpcamid = ui->cam1->currentText();
tmpcamimg1 = ui->cam1img1;
tmpcamimg2 = ui->cam1img2;
tmpcamimg3 = ui->cam1img3;
tmpcamimg4 = ui->cam1img4;
tmpcamimg5 = ui->cam1img5;
break;
case 1: tmpcamid = ui->cam2->currentText();
tmpcamimg1 = ui->cam2img1;
tmpcamimg2 = ui->cam2img2;
tmpcamimg3 = ui->cam2img3;
tmpcamimg4 = ui->cam2img4;
tmpcamimg5 = ui->cam2img5;
break;
case 2: tmpcamid = ui->cam3->currentText();
tmpcamimg1 = ui->cam3img1;
tmpcamimg2 = ui->cam3img2;
tmpcamimg3 = ui->cam3img3;
tmpcamimg4 = ui->cam3img4;
tmpcamimg5 = ui->cam3img5;
break;
case 3: tmpcamid = ui->cam4->currentText();
tmpcamimg1 = ui->cam4img1;
tmpcamimg2 = ui->cam4img2;
tmpcamimg3 = ui->cam4img3;
tmpcamimg4 = ui->cam4img4;
tmpcamimg5 = ui->cam4img5;
break;
case 4: tmpcamid = ui->cam5->currentText();
tmpcamimg1 = ui->cam5img1;
tmpcamimg2 = ui->cam5img2;
tmpcamimg3 = ui->cam5img3;
tmpcamimg4 = ui->cam5img4;
tmpcamimg5 = ui->cam5img5;
break;
default:break;
}
__int64 & tmpcurrentfc = getTmpCurrentfc(i);
if (tmpcamid.trimmed().compare("") == 0)
{
tmpcamimg1->clear();
tmpcamimg2->clear();
tmpcamimg3->clear();
tmpcamimg4->clear();
tmpcamimg5->clear();
continue;
}
tmpcamimgdir = currenttmpimgpath + "_" + tmpcamid + "/";
// 每个相机的5张图
for (int j = -2; j < 3; j++)
{
switch (j)
{
case -2: tmpcamimg = tmpcamimg1; break;
case -1: tmpcamimg = tmpcamimg2; break;
case 0: tmpcamimg = tmpcamimg3; break;
case 1: tmpcamimg = tmpcamimg4; break;
case 2: tmpcamimg = tmpcamimg5; break;
default:break;
}
QString filename3 = (QString("%1/%2.jpg").arg(tmpcamimgdir).arg(tmpcurrentfc + j));
if (!QFile(filename3).exists())
{
// 清空显示
tmpcamimg->clear();
qDebug() << QObject::tr("图片目录:") << filename3 << QObject::tr("不存在!");
ret = false;
//.........这里部分代码省略.........
开发者ID:fanxiang090909,项目名称:Railway-Tunnel-Construction-Dlearance-Measure-LanZhou,代码行数:101,代码来源:imageviewer.cpp
示例9: updateData
void LapTimeComparisonDialog::updateData()
{
int scrollBarPosition = ui->tableWidget->verticalScrollBar()->sliderPosition();
QItemSelectionModel * selection = ui->tableWidget->selectionModel();
// for (int i = ui->tableWidget->rowCount()-1; i >= 0; --i)
// ui->tableWidget->removeRow(i);
QTableWidgetItem *item;
int firstLap = 99, lastLap = 0;
int index[4];
QString wTitle = "Lap time comparison: ";
for (int i = 0; i < 4; ++i)
{
index[i] = 0;
int idx = eventData.getDriverId(getNumber(i));
if (idx > 0)
{
if (i > 0)
wTitle += " - ";
wTitle += eventData.getDriversData()[idx-1].getDriverName();
if(!eventData.getDriversData()[idx-1].getLapData().isEmpty())
{
if (eventData.getDriversData()[idx-1].getLapData()[0].getLapNumber() < firstLap)
firstLap = eventData.getDriversData()[idx-1].getLapData()[0].getLapNumber();
if (eventData.getDriversData()[idx-1].getLapData().last().getLapNumber() > lastLap)
lastLap = eventData.getDriversData()[idx-1].getLapData().last().getLapNumber();
}
DriverData &dd = eventData.getDriversData()[idx-1];
QLabel *lab = qobject_cast<QLabel*>(ui->tableWidget->cellWidget(0, i+1));
lab->setPixmap(ImagesFactory::getInstance().getCarThumbnailsFactory().getCarThumbnail(dd.getNumber(), thumbnailsSize));//eventData.carImages[idx].scaledToWidth(120, Qt::SmoothTransformation));
}
else
{
QLabel *lab = qobject_cast<QLabel*>(ui->tableWidget->cellWidget(0, i+1));
lab->clear();
}
}
setWindowTitle(wTitle);
// ui->tableWidget->insertRow(0);
// ui->tableWidget->setRowHeight(0, 50);
int j = 0, k = firstLap;
for (; k <= lastLap; ++k, ++j)
{
int lapNo = lastLap - k + firstLap;
LapTime laps[4];
if (ui->tableWidget->rowCount() <= j+1)
ui->tableWidget->insertRow(j+1);
item = ui->tableWidget->item(j+1, 0);
if (!item)
{
item = new QTableWidgetItem(QString("%1.").arg(lapNo));
// item->setFlags(Qt::ItemIsSelectable);
item->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
item->setTextColor(ColorsManager::getInstance().getColor(LTPackets::DEFAULT));
ui->tableWidget->setItem(j+1, 0, item);
}
else
item->setText(QString("%1.").arg(lapNo));
for (int i = 0; i < 4; ++i)
{
int idx = eventData.getDriverId(getNumber(i));
if (idx > 0 && !eventData.getDriversData()[idx-1].getLapData().isEmpty())
{
//int lapIndex = (reversedOrder ? eventData.driversData[idx-1].lapData.size() - index[i] - 1 : index[i]);
DriverData &dd = eventData.getDriversData()[idx-1];
LapData ld = dd.getLapData(lapNo);
// if (j == 0)
// {
// int idx = (dd.number > 13 ? dd.number-2 : dd.number-1) / 2;
// QLabel *lab = qobject_cast<QLabel*>(ui->tableWidget->cellWidget(0, i+1));
// lab->setPixmap(smallCarImg[idx]);//eventData.carImages[idx].scaledToWidth(120, Qt::SmoothTransformation));
// }
if (dd.getLapData().size() > index[i] && ld.getLapNumber() == lapNo && ld.getCarID() != -1)
{
laps[i] = ld.getTime();
item = ui->tableWidget->item(j+1, i+1);
if (!item)
{
item = new QTableWidgetItem(ld.getTime());
item->setTextAlignment(Qt::AlignCenter);
ui->tableWidget->setItem(j+1, i+1, item);
}
else
item->setText(ld.getTime());
//.........这里部分代码省略.........
示例10: main
//.........这里部分代码省略.........
meth->addItem("sha512");
meth->setToolTip(Window::tr("Hashing method"));
meth->setCurrentText(settings.value("HashingMethod", "md5").toString());
QObject::connect(&window, &Window::idle, meth, &QWidget::setEnabled);
QObject::connect(meth, &QComboBox::currentTextChanged,
[&](const QString &text) { settings.setValue("HashingMethod", text); });
/* toolbar */
QHBoxLayout *pane = new QHBoxLayout;
pane->addWidget(hash, 0, Qt::AlignLeft);
pane->addWidget(stack);
pane->addWidget(meth, 0, Qt::AlignRight);
/* main layout */
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(text);
layout->addLayout(pane);
/* the window */
window.centralWidget()->setLayout(layout);
window.show();
/* future hashing */
QFutureWatcher<Vals> zu;
QObject::connect(&zu, &QFutureWatcher<Vals>::finished,
[&]() {
Vals valsi = zu.future().result();
window.idle(true);
if (valsi.path == "") {
error->setText(QString::fromStdString(valsi.name));
hash->setChecked(false);
} else {
error->clear();
vals += valsi;
test->textChanged(test->text());
}
});
QObject::connect(meth, &QComboBox::currentTextChanged,
[&](const QString &text) { if (vals.name != "") {
window.idle(false);
zu.setFuture(QtConcurrent::run(&update, text, vals));
}});
QObject::connect(&window, &Window::fileDroped,
[&](const QString &name, const QString &path) {
window.idle(false);
zu.setFuture(QtConcurrent::run(&update, meth->currentText(), Vals(name, path)));
});
/* hashing info */
QGraphicsBlurEffect blur;
blur.setBlurHints(QGraphicsBlurEffect::AnimationHint);
QPropertyAnimation anim(&blur, "blurRadius");
anim.setDuration(2000);
anim.setLoopCount(-1);
anim.setKeyValueAt(0, 0);
anim.setKeyValueAt(0.5, 3);
anim.setKeyValueAt(1, 0);
QLabel *hashing = new QLabel;
hashing->setPixmap(QPixmap(":/icon"));
hashing->setAttribute(Qt::WA_TransparentForMouseEvents);
hashing->setGraphicsEffect(&blur);