本文整理汇总了C++中QLabel::setNum方法的典型用法代码示例。如果您正苦于以下问题:C++ QLabel::setNum方法的具体用法?C++ QLabel::setNum怎么用?C++ QLabel::setNum使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLabel
的用法示例。
在下文中一共展示了QLabel::setNum方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QGroupBox
/*******************************************************************************
* Initializes the dynamic parameter sliders.
*/
QWidget*
MainWindow::initDynamicParametersGroupBox(QWidget* parent)
{
QGroupBox* group = new QGroupBox(tr("Dynamic Parameters"), parent);
QGridLayout* layout = new QGridLayout(group);
layout->setColumnStretch(0, 1);
layout->setColumnStretch(1, 4);
layout->setColumnStretch(2, 1);
std::size_t i = 0;
for ( ; i < dynamicParamInfoList.size(); ++i) {
// Label.
layout->addWidget(new QLabel(dynamicParamInfoList[i].name, group), i, 0);
// Slider.
dynamicParamSliderList_[i] = new ParameterSlider(i,
configuration_->dynamicParamMinList[i], configuration_->dynamicParamMaxList[i],
configuration_->dynamicParamList[i], group);
layout->addWidget(dynamicParamSliderList_[i], i, 1);
// Value.
QString s;
s.setNum(0.0);
QLabel* valueLabel = new QLabel(s, group);
layout->addWidget(valueLabel, i, 2);
connect(dynamicParamSliderList_[i], SIGNAL(valueChanged(int, float)), this, SLOT(setDynamicParameter(int, float)));
connect(dynamicParamSliderList_[i], SIGNAL(valueChanged(double)), valueLabel, SLOT(setNum(double)));
valueLabel->setNum(dynamicParamSliderList_[i]->parameterValue());
}
// Stretch.
layout->addWidget(new QWidget(group), i, 0, 1, 3);
layout->setRowStretch(i, 1);
return group;
}
示例2: setUp_SpiralTable
void firstPage::setUp_SpiralTable(){
////////////////////////////////////////////
// Set up spiral Table //
////////////////////////////////////////////
spiralTable=ui->spiralTable;
spiralTable->verticalHeader()->setVisible(false);
spiralTable->horizontalHeader()->setVisible(false);
spiralTable->setShowGrid(false);
//Format 1. Column
for(int i = 0; i<spiralTable->rowCount() ; i++)
{
spiralTable->item(i,0)->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
}
//////////////////////////////////////////////////////////
// Put DoubleSpinBoxes in 2.Column of Table //
//////////////////////////////////////////////////////////
for( int i = 0; i < spiralTable->rowCount(); i++ )
{
QDoubleSpinBox *spinBox = new QDoubleSpinBox();
spinBox->setValue(0);
spiralTable->setCellWidget( i, 1, spinBox );
}
static_cast<QSpinBox*>(spiralTable->cellWidget(0,1))->setMinimum(0);
static_cast<QSpinBox*>(spiralTable->cellWidget(0,1))->setMaximum(maxA/2);
static_cast<QSpinBox*>(spiralTable->cellWidget(1,1))->setMinimum(0);
static_cast<QSpinBox*>(spiralTable->cellWidget(1,1))->setMaximum(maxA/2);
static_cast<QSpinBox*>(spiralTable->cellWidget(2,1))->setMinimum(0);
static_cast<QSpinBox*>(spiralTable->cellWidget(2,1))->setMaximum(10000);
static_cast<QSpinBox*>(spiralTable->cellWidget(3,1))->setMinimum(0);
static_cast<QSpinBox*>(spiralTable->cellWidget(3,1))->setMaximum(10000);
static_cast<QSpinBox*>(spiralTable->cellWidget(4,1))->setMinimum(-1000);
static_cast<QSpinBox*>(spiralTable->cellWidget(4,1))->setMaximum(1000);
static_cast<QSpinBox*>(spiralTable->cellWidget(5,1))->setMinimum(-1000);
static_cast<QSpinBox*>(spiralTable->cellWidget(5,1))->setMaximum(1000);
static_cast<QSpinBox*>(spiralTable->cellWidget(6,1))->setMinimum(-1000);
static_cast<QSpinBox*>(spiralTable->cellWidget(6,1))->setMaximum(1000);
static_cast<QSpinBox*>(spiralTable->cellWidget(7,1))->setMinimum(0);
static_cast<QSpinBox*>(spiralTable->cellWidget(7,1))->setMaximum(veloMax);
////////////////////////////////////////////////////////////////////////
// Load stored values and assign them in 3. and 2. Column //
////////////////////////////////////////////////////////////////////////
cout<<mSpiral.getStoredValuesPath()<<endl;
QFile spiralFile(QString::fromStdString(mSpiral.getStoredValuesPath()));
spiralFile.open(QIODevice::ReadOnly | QIODevice::Text);
QTextStream inspiral(&spiralFile);
for( int i = 0; i < spiralTable->rowCount(); i++ )
{
QLabel *label = new QLabel();
double x = inspiral.readLine().toDouble();
if((i==4)||(i==5)||(i==6)){
x=(x/(2*pi))*360;
}
label->setNum(x);
cout<<x<<endl;
label->setAlignment(Qt::AlignVCenter);
spiralTable->setCellWidget( i, 3, label );
static_cast<QDoubleSpinBox*>(spiralTable->cellWidget(i,1))->setValue(x);
}
spiralFile.close();
//make 1. Column unaccesible
for(int i = 0;i<spiralTable->rowCount();i++){
spiralTable->item(i,0)->setFlags(spiralTable->item(i,0)->flags() ^ Qt::ItemIsEditable);
spiralTable->item(i,0)->setFlags(spiralTable->item(i,0)->flags() ^ Qt::ItemIsSelectable);
spiralTable->item(i,0)->setFlags(spiralTable->item(i,0)->flags() ^ Qt::ItemIsUserCheckable);
//spiralTable->item(i,0)->setFlags(spiralTable->item(i,0)->flags() ^ Qt::ItemIsEnabled);
}
spiralTable->setColumnWidth(2,cWidth);
spiralTable->setTabKeyNavigation(false);
}
示例3: setUp_LineTable
void firstPage::setUp_LineTable(){
lineTable=ui->lineTable;
lineTable->verticalHeader()->setVisible(false);
lineTable->horizontalHeader()->setVisible(false);
lineTable->setShowGrid(false);
//column 2 is only used as a spacer
lineTable->setColumnWidth(2,cWidth);
lineTable->setTabKeyNavigation(false);
//////////////////////////////////////////
// Format 1. Column //
//////////////////////////////////////////
for(int i = 0; i<lineTable->rowCount() ; i++)
{
lineTable->item(i,0)->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
}
//make 1. Column unaccesible
for(int i = 0;i<lineTable->rowCount();i++){
lineTable->item(i,0)->setFlags(lineTable->item(i,0)->flags() ^ Qt::ItemIsEditable);
lineTable->item(i,0)->setFlags(lineTable->item(i,0)->flags() ^ Qt::ItemIsSelectable);
lineTable->item(i,0)->setFlags(lineTable->item(i,0)->flags() ^ Qt::ItemIsUserCheckable);
}
// http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/MAC/GREEK.TXT
lineTable->item(1,0)->setText(QString(QChar(0x03C6))+" =");
lineTable->item(2,0)->setText(QString(QChar(0x0398))+" =");
//////////////////////////////////////////////////////////
// Put DoubleSpinBoxes in 2.Column of Table //
//////////////////////////////////////////////////////////
for( int i = 0; i < lineTable->rowCount(); i++ )
{
if(i==3){
QSpinBox *spinBox = new QSpinBox();
spinBox->setValue(0);
lineTable->setCellWidget( i, 1, spinBox );
}else
{
QDoubleSpinBox *spinBox = new QDoubleSpinBox();
spinBox->setValue(0);
lineTable->setCellWidget( i, 1, spinBox );
}
}
//Format SpinBoxes Manually
static_cast<QSpinBox*>(lineTable->cellWidget(0,1))->setMinimum(0);
static_cast<QSpinBox*>(lineTable->cellWidget(0,1))->setMaximum(maxA/2);
static_cast<QSpinBox*>(lineTable->cellWidget(1,1))->setMinimum(-1000);
static_cast<QSpinBox*>(lineTable->cellWidget(1,1))->setMaximum(1000);
static_cast<QSpinBox*>(lineTable->cellWidget(2,1))->setMinimum(-1000);
static_cast<QSpinBox*>(lineTable->cellWidget(2,1))->setMaximum(1000);
static_cast<QSpinBox*>(lineTable->cellWidget(3,1))->setMinimum(1);
static_cast<QSpinBox*>(lineTable->cellWidget(3,1))->setMaximum(1000);
static_cast<QSpinBox*>(lineTable->cellWidget(4,1))->setMinimum(0);
static_cast<QSpinBox*>(lineTable->cellWidget(4,1))->setMaximum(veloMax);
////////////////////////////////////////////////////////////////////////
// Load stored values and assign them in 3. and 2. Column //
////////////////////////////////////////////////////////////////////////
cout<<mLine.getStoredValuesPath()<<endl;
QFile lineFile(QString::fromStdString(mLine.getStoredValuesPath()));
lineFile.open(QIODevice::ReadOnly | QIODevice::Text);
QTextStream inLine(&lineFile);
for( int i = 0; i < lineTable->rowCount(); i++ )
{
if(i==3){
QLabel *label = new QLabel();
int x = inLine.readLine().toInt();
label->setNum(x);
cout<<x<<endl;
label->setAlignment(Qt::AlignVCenter);
lineTable->setCellWidget( i, 3, label );
static_cast<QSpinBox*>(lineTable->cellWidget(i,1))->setValue(x);
}else
{
QLabel *label = new QLabel();
double x = inLine.readLine().toDouble();
if((i==1)||(i==2)){
x=(x/(2*pi))*360;
}
label->setNum(x);
cout<<x<<endl;
label->setAlignment(Qt::AlignVCenter);
//.........这里部分代码省略.........
示例4: open_settingsDialog
bool QVideoCapture::open_settingsDialog()
{
if (m_cvCapture.isOpened() && deviceFlag)
{
//DIALOG CONSTRUCTION//
QDialog dialog;
dialog.setFixedSize(256,320);
dialog.setWindowTitle(tr("Camcorder settings"));
QVBoxLayout toplevellayout;
toplevellayout.setMargin(5);
QTabWidget tabwidget;
QWidget page1; // a widget for a cam general settings selection
QHBoxLayout centralbox;
centralbox.setMargin(5);
QVBoxLayout sliders;
sliders.setMargin(5);
QVBoxLayout lineedits;
lineedits.setMargin(5);
QVBoxLayout names;
names.setMargin(5);
QSlider Sbrightness;
Sbrightness.setOrientation(Qt::Horizontal);
Sbrightness.setMinimum(MIN_BRIGHTNESS);
Sbrightness.setMaximum(MAX_BRIGHTNESS);
Sbrightness.setValue( (int)m_cvCapture.get(CV_CAP_PROP_BRIGHTNESS) );
QLabel Lbrightness;
Lbrightness.setNum( (int)m_cvCapture.get(CV_CAP_PROP_BRIGHTNESS) );
connect(&Sbrightness, SIGNAL(valueChanged(int)), &Lbrightness, SLOT(setNum(int)));
connect(&Sbrightness, SIGNAL(valueChanged(int)), this, SLOT(set_brightness(int)));
connect(this, SIGNAL(set_default_brightness(int)), &Sbrightness, SLOT(setValue(int)));
QLabel Nbrightness("Brightness:");
QSlider Scontrast;
Scontrast.setOrientation(Qt::Horizontal);
Scontrast.setMinimum(MIN_CONTRAST);
Scontrast.setMaximum(MAX_CONTRAST);
Scontrast.setValue( (int)m_cvCapture.get(CV_CAP_PROP_CONTRAST) );
QLabel Lcontrast;
Lcontrast.setNum( (int)m_cvCapture.get(CV_CAP_PROP_CONTRAST) );
connect(&Scontrast, SIGNAL(valueChanged(int)), &Lcontrast, SLOT(setNum(int)));
connect(&Scontrast,SIGNAL(valueChanged(int)), this, SLOT(set_contrast(int)));
connect(this, SIGNAL(set_default_contrast(int)), &Scontrast, SLOT(setValue(int)));
QLabel Ncontrast("Contrast:");
QSlider Ssaturation;
Ssaturation.setOrientation(Qt::Horizontal);
Ssaturation.setMinimum(MIN_SATURATION);
Ssaturation.setMaximum(MAX_SATURATION);
Ssaturation.setValue( (int)m_cvCapture.get(CV_CAP_PROP_SATURATION) );
QLabel Lsaturation;
Lsaturation.setNum( (int)m_cvCapture.get(CV_CAP_PROP_SATURATION) );
connect(&Ssaturation, SIGNAL(valueChanged(int)), &Lsaturation, SLOT(setNum(int)));
connect(&Ssaturation,SIGNAL(valueChanged(int)), this, SLOT(set_saturation(int)));
connect(this, SIGNAL(set_default_saturation(int)), &Ssaturation, SLOT(setValue(int)));
QLabel Nsaturation("Saturation:");
QSlider SwhitebalanceU;
SwhitebalanceU.setOrientation(Qt::Horizontal);
SwhitebalanceU.setMinimum(MIN_WHITE_BALANCE);
SwhitebalanceU.setMaximum(MAX_WHITE_BALANCE);
SwhitebalanceU.setValue( (int)m_cvCapture.get(CV_CAP_PROP_WHITE_BALANCE_BLUE_U) );
QLabel LwhitebalanceU;
LwhitebalanceU.setNum( (int)m_cvCapture.get(CV_CAP_PROP_WHITE_BALANCE_BLUE_U) );
connect(&SwhitebalanceU, SIGNAL(valueChanged(int)), &LwhitebalanceU, SLOT(setNum(int)));
connect(&SwhitebalanceU,SIGNAL(valueChanged(int)), this, SLOT(set_white_balanceU(int)));
connect(this, SIGNAL(set_default_white_balanceU(int)), &SwhitebalanceU, SLOT(setValue(int)));
QLabel NwhitebalanceU("White_balanceU:");
QSlider SwhitebalanceV;
SwhitebalanceV.setOrientation(Qt::Horizontal);
SwhitebalanceV.setMinimum(MIN_WHITE_BALANCE);
SwhitebalanceV.setMaximum(MAX_WHITE_BALANCE);
SwhitebalanceV.setValue( (int)m_cvCapture.get(CV_CAP_PROP_WHITE_BALANCE_RED_V) );
QLabel LwhitebalanceV;
LwhitebalanceV.setNum( (int)m_cvCapture.get(CV_CAP_PROP_WHITE_BALANCE_RED_V) );
connect(&SwhitebalanceV, SIGNAL(valueChanged(int)), &LwhitebalanceV, SLOT(setNum(int)));
connect(&SwhitebalanceV,SIGNAL(valueChanged(int)), this, SLOT(set_white_balanceV(int)));
connect(this, SIGNAL(set_default_white_balanceV(int)), &SwhitebalanceV, SLOT(setValue(int)));
QLabel NwhitebalanceV("White_balanceV:");
sliders.addWidget(&Sbrightness);
lineedits.addWidget(&Lbrightness, 2);
names.addWidget(&Nbrightness, 1);
sliders.addWidget(&Scontrast);
lineedits.addWidget(&Lcontrast, 2);
names.addWidget(&Ncontrast, 1);
sliders.addWidget(&Ssaturation);
lineedits.addWidget(&Lsaturation, 2);
names.addWidget(&Nsaturation, 1);
sliders.addWidget(&SwhitebalanceU);
lineedits.addWidget(&LwhitebalanceU, 2);
names.addWidget(&NwhitebalanceU, 1);
sliders.addWidget(&SwhitebalanceV);
//.........这里部分代码省略.........