本文整理汇总了C++中QSpinBox::setPrefix方法的典型用法代码示例。如果您正苦于以下问题:C++ QSpinBox::setPrefix方法的具体用法?C++ QSpinBox::setPrefix怎么用?C++ QSpinBox::setPrefix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSpinBox
的用法示例。
在下文中一共展示了QSpinBox::setPrefix方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: versionSpinboxValueChangedSlot
/**
* Is called if the value of one of the version combo boxes has been changed.
* @param value
*/
void CreateSceFile::versionSpinboxValueChangedSlot(int value)
{
QObject* obj = sender();
QSpinBox* box = static_cast<QSpinBox*>(obj);
if(value < 10)
{
box->setPrefix("0");
}
else
{
box->setPrefix("");
}
}
示例2: if
TtipMelody::TtipMelody(TquestionPoint *point) :
TtipChart(point)
{
setBgColor(point->color());
setPlainText(" ");
m_w = new QWidget();
m_w->setObjectName("m_melodyView");
m_w->setStyleSheet("QWidget#m_melodyView { background: transparent }");
QString txt;
if (point->nr())
txt = QString(TquestionAsWdg::questionTxt() + " <big><b>%1.</b></big>").arg(point->nr());
if (point->question()->questionAsNote() && point->question()->answerAsSound())
txt += (" <b>" + TexTrans::playMelodyTxt() + "</b>");
else if (point->question()->questionAsSound() && point->question()->answerAsNote())
txt += (" <b>" + TexTrans::writeMelodyTxt() + "</b>");
QLabel *headLab = new QLabel(txt, m_w);
headLab->setAlignment(Qt::AlignCenter);
m_score = new TmelodyView(qa()->question()->melody(), m_w);
m_score->setFixedHeight(qApp->desktop()->availableGeometry().height() / 12);
if (point->question()->exam()) {
if (point->question()->exam()->level()->showStrNr)
m_score->showStringNumbers(true);
}
QSpinBox *spinAtt = new QSpinBox(m_w);
spinAtt->setRange(0, qa()->question()->attemptsCount());
spinAtt->setPrefix(TexTrans::attemptTxt() + " ");
spinAtt->setSuffix(" " + tr("of", "It will give text: 'Attempt x of y'") + QString(" %1").arg(qa()->question()->attemptsCount()));
m_attemptLabel = new QLabel(m_w);
m_resultLabel = new QLabel(wasAnswerOKtext(point->question(), point->color()).replace("<br>", " "), m_w);
m_resultLabel->setAlignment(Qt::AlignCenter);
// txt = wasAnswerOKtext(point->question(), point->color()).replace("<br>", " ") + "<br>";
txt = tr("Melody was played <b>%n</b> times", "", qa()->question()->totalPlayBacks()) + "<br>";
txt += TexTrans::effectTxt() + QString(": <big><b>%1%</b></big>, ").arg(point->question()->effectiveness(), 0, 'f', 1, '0');
txt += TexTrans::reactTimeTxt() + QString("<big><b> %1</b></big>").arg(Texam::formatReactTime(point->question()->time, true));
QLabel *sumLab = new QLabel(txt, m_w);
sumLab->setAlignment(Qt::AlignCenter);
QVBoxLayout *lay = new QVBoxLayout;
lay->addWidget(headLab);
lay->addWidget(m_score, 0, Qt::AlignCenter);
QHBoxLayout *attLay = new QHBoxLayout;
attLay->addStretch();
attLay->addWidget(spinAtt);
attLay->addStretch();
lay->addLayout(attLay);
lay->addWidget(m_attemptLabel);
lay->addWidget(m_resultLabel);
lay->addWidget(sumLab);
m_w->setLayout(lay);
m_widget = point->scene()->addWidget(m_w);
m_widget->setParentItem(this);
connect(spinAtt, SIGNAL(valueChanged(int)), this, SLOT(attemptChanged(int)));
}
示例3: createSpinBoxes
//! [1]
void Window::createSpinBoxes()
{
spinBoxesGroup = new QGroupBox(tr("Spinboxes"));
QLabel *integerLabel = new QLabel(tr("Enter a value between "
"%1 and %2:").arg(-20).arg(20));
QSpinBox *integerSpinBox = new QSpinBox;
integerSpinBox->setRange(-20, 20);
integerSpinBox->setSingleStep(1);
integerSpinBox->setValue(0);
//! [1]
//! [2]
QLabel *zoomLabel = new QLabel(tr("Enter a zoom value between "
"%1 and %2:").arg(0).arg(1000));
//! [3]
QSpinBox *zoomSpinBox = new QSpinBox;
zoomSpinBox->setRange(0, 1000);
zoomSpinBox->setSingleStep(10);
zoomSpinBox->setSuffix("%");
zoomSpinBox->setSpecialValueText(tr("Automatic"));
zoomSpinBox->setValue(100);
//! [2] //! [3]
//! [4]
QLabel *priceLabel = new QLabel(tr("Enter a price between "
"%1 and %2:").arg(0).arg(999));
QSpinBox *priceSpinBox = new QSpinBox;
priceSpinBox->setRange(0, 999);
priceSpinBox->setSingleStep(1);
priceSpinBox->setPrefix("$");
priceSpinBox->setValue(99);
//! [4] //! [5]
QVBoxLayout *spinBoxLayout = new QVBoxLayout;
spinBoxLayout->addWidget(integerLabel);
spinBoxLayout->addWidget(integerSpinBox);
spinBoxLayout->addWidget(zoomLabel);
spinBoxLayout->addWidget(zoomSpinBox);
spinBoxLayout->addWidget(priceLabel);
spinBoxLayout->addWidget(priceSpinBox);
spinBoxesGroup->setLayout(spinBoxLayout);
}
示例4: QueryPage
QueryPage:: QueryPage(QWidget *parent)
: QWidget(parent)
{
QGroupBox *packagesGroup = new QGroupBox("Look for packages");
QLabel *nameLabel = new QLabel("Name:");
QLineEdit *nameLineEdit = new QLineEdit;
QLabel *dateLabel = new QLabel("Released after:");
QDateTimeEdit *dateEdit = new QDateTimeEdit(QDate::currentDate());
QCheckBox *releaseCheckBox = new QCheckBox("Releases");
QCheckBox *upgradesCheckBox = new QCheckBox("Upgrades");
QSpinBox *hitsSpinBox = new QSpinBox;
hitsSpinBox->setPrefix("Return up to");
hitsSpinBox->setSuffix(" results");
hitsSpinBox->setSpecialValueText("Return only the first result");
hitsSpinBox->setMinimum(1);
hitsSpinBox->setMaximum(100);
hitsSpinBox->setSingleStep(10);
QPushButton *startQueryButton = new QPushButton("Start query");
QGridLayout *packagesLayout = new QGridLayout;
packagesLayout->addWidget(nameLabel, 0, 0);
packagesLayout->addWidget(nameLineEdit, 0, 1);
packagesLayout->addWidget(dateLabel, 1, 0);
packagesLayout->addWidget(dateEdit, 1, 1);
packagesLayout->addWidget(releaseCheckBox, 2, 0);
packagesLayout->addWidget(upgradesCheckBox, 3, 0);
packagesLayout->addWidget(hitsSpinBox, 4, 0, 1, 2);
packagesGroup->setLayout(packagesLayout);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(packagesGroup);
mainLayout->addSpacing(12);
mainLayout->addWidget(startQueryButton);
mainLayout->addStretch(1);
setLayout(mainLayout);
}
示例5: QMainWindow
VPiano::VPiano() : QMainWindow()
{
QWidget *central = new QWidget(this);
QVBoxLayout *vb = new QVBoxLayout;
QHBoxLayout *octaves = new QHBoxLayout;
QSignalMapper *octaveSignalMapper = new QSignalMapper(this);
for(int i = 0; i < 9; i++)
{
QString title;
title.setNum(i);
QPushButton *o = new QPushButton(title, central);
o->setFixedSize(fontMetrics().width(title)*4, o->height());
QString shortcut;
shortcut.setNum(i+1);
o->setShortcut(QKeySequence(QString("F") + shortcut));
octaves->addWidget(o);
connect(o, SIGNAL(clicked()), octaveSignalMapper, SLOT(map()));
octaveSignalMapper->setMapping(o, i);
}
OctaveRangeWidget *octRange = new OctaveRangeWidget(central);
octaves->addWidget(octRange);
QSlider *velocity = new QSlider(Qt::Horizontal, central);
velocity->setMinimum(1);
velocity->setMaximum(127);
velocity->setValue(96); // TODO: read prev value from config
velocity->setToolTip(tr("Velocity"));
octaves->addWidget(velocity);
QSpinBox *channel = new QSpinBox(central);
channel->setPrefix(tr("Ch ", "Midi Channel number"));
channel->setMinimum(0);
channel->setMaximum(127);
channel->setValue(0); // TODO: read prev value from config
channel->setToolTip(tr("Select MIDI channel number to send messages to"));
octaves->addWidget(channel);
vb->addLayout(octaves);
QHBoxLayout *keyarea = new QHBoxLayout;
KeyboardWidget *kw = new KeyboardWidget(central);
keyarea->addWidget(kw);
QVBoxLayout *rightside = new QVBoxLayout;
QSlider *pitchWheel = new QSlider(Qt::Vertical, central);
pitchWheel->setMinimum(-64);
pitchWheel->setMaximum(63);
pitchWheel->setValue(0); // TODO: read prev value from config
pitchWheel->setToolTip(tr("Pitch wheel"));
rightside->addWidget(pitchWheel);
QCheckBox *porta = new QCheckBox(central);
porta->setToolTip(tr("Enable portamento"));
rightside->addWidget(porta);
keyarea->addLayout(rightside);
vb->addLayout(keyarea);
central->setLayout(vb);
setCentralWidget(central);
setWindowTitle(tr("Virtual MIDI keyboard"));
// TODO: connect pitchWheel
connect(octaveSignalMapper, SIGNAL(mapped(int)), kw, SLOT(octaveSelected(int)));
connect(channel, SIGNAL(valueChanged(int)), kw, SLOT(midiChannelSelected(int)));
connect(kw, SIGNAL(highlightOctaves(int,int)), octRange, SLOT(highlightOctaves(int,int)));
kw->octaveSelected(0); // TODO: use value read from config
}
示例6: openPix
//.........这里部分代码省略.........
viewMenu->addSeparator();
QPixmap zoomInPix("img/zoom_in.png");
QAction* zoomIn = new QAction(zoomInPix, "&Zoom In", this);
viewMenu->addAction(zoomIn);
QPixmap zoomOutPix("img/zoom_out.png");
QAction* zoomOut = new QAction(zoomOutPix, "&Zoom Out", this);
viewMenu->addAction(zoomOut);
QPixmap zoom100Pix("img/zoom.png");
QAction* zoom100 = new QAction(zoom100Pix, "&Actual Size", this);
viewMenu->addAction(zoom100);
// Help Menus
QMenu* helpMenu = new QMenu("Help");
QPixmap aboutPix("img/star.png");
QAction* about = new QAction(aboutPix, "&About", this);
helpMenu->addAction(about);
menuBar->addMenu(fileMenu);
menuBar->addMenu(editMenu);
menuBar->addMenu(viewMenu);
menuBar->addMenu(helpMenu);
// ToolBar
QToolBar* toolBar = new QToolBar(canvas);
toolBar->addAction(open);
toolBar->addSeparator();
toolBar->addAction(save);
toolBar->addAction(saveAs);
toolBar->addSeparator();
toolBar->addAction(cut);
toolBar->addAction(copy);
toolBar->addAction(paste);
toolBar->addSeparator();
toolBar->addAction(viewGrid);
toolBar->addSeparator();
QSpinBox* gridX = new QSpinBox(this);
gridX->setPrefix("X: ");
toolBar->addWidget(gridX);
toolBar->addSeparator();
QSpinBox* gridY = new QSpinBox(this);
gridY->setPrefix("Y: ");
toolBar->addWidget(gridY);
toolBar->addSeparator();
toolBar->addAction(zoomIn);
toolBar->addAction(zoomOut);
toolBar->addAction(zoom100);
toolBar->addSeparator();
QDoubleSpinBox* speed = new QDoubleSpinBox(this);
speed->setPrefix("Speed: ");
speed->setDecimals(3);
speed->setSingleStep(0.001);
speed->setAccelerated(true);
toolBar->addWidget(speed);
mainLayout->addWidget(canvas);
setMenuBar(menuBar);
addToolBar(toolBar);
toolBar->addSeparator();
QPixmap playPix("img/play.png");
QAction* play = new QAction(playPix, "&Play", this);
toolBar->addAction(play);
QPixmap pausePix("img/pause.png");
QAction* pause = new QAction(pausePix, "&Pause", this);
toolBar->addAction(pause);
QPixmap stopPix("img/stop.png");
QAction* stop = new QAction(stopPix, "&Stop", this);
toolBar->addAction(stop);
toolBar->addSeparator();
QSpinBox* frame = new QSpinBox(this);
frame->setPrefix("Frame: ");
toolBar->addWidget(frame);
mainLayout->setMargin(0);
centralWidget->setLayout(mainLayout);
}
示例7: sMapChanged
//.........这里部分代码省略.........
CSVMapField f = map.field(fList.at(i));
if(!record.contains(fList.at(i)))
{
map.removeField(fList.at(i));
MissingField diag(this, f.name(), record);
if(diag.exec() == QDialog::Accepted)
{
f.setName(diag._fields->currentText());
map.setField(f);
}
_atlas->setMap(map);
}
}
for (int i = 0; i < record.count(); i++)
fieldnames.append(record.fieldName(i));
}
_fields->setRowCount(fieldnames.size());
for(int row = 0; row < fieldnames.size(); ++row)
{
CSVMapField mf = map.field(fieldnames.at(row));
QCheckBox *check = new QCheckBox(_fields);
if(!mf.isEmpty())
check->setChecked(mf.isKey());
_fields->setCellWidget(row, 0, check);
_fields->setItem(row, 1, new QTableWidgetItem(fieldnames.at(row)));
if (record.isEmpty())
{
_fields->setItem(row, 2,
new QTableWidgetItem(QVariant::typeToName(mf.type())));
_fields->setItem(row, 3, new QTableWidgetItem(tr("Unknown")));
}
else
{
_fields->setItem(row, 2,
new QTableWidgetItem(QVariant::typeToName(record.field(row).type())));
_fields->setItem(row, 3, new QTableWidgetItem(
(record.field(row).requiredStatus() == QSqlField::Required) ? tr("Yes") :
(record.field(row).requiredStatus() == QSqlField::Optional) ? tr("No") :
tr("Unknown")));
}
QComboBox *actcombo = new QComboBox(_fields);
actcombo->addItems(CSVMapField::actionList());
if (! mf.isEmpty())
actcombo->setCurrentIndex(mf.action());
_fields->setCellWidget(row, 4, actcombo);
QSpinBox *colspinner = new QSpinBox(_fields);
colspinner->setRange(1, 999);
colspinner->setPrefix(tr("Column "));
if(!mf.isEmpty())
colspinner->setValue(mf.column());
_fields->setCellWidget(row, 5, colspinner);
QComboBox *nullcombo = new QComboBox(_fields);
nullcombo->addItems(CSVMapField::ifNullList());
if (! mf.isEmpty())
nullcombo->setCurrentIndex(mf.ifNullAction());
_fields->setCellWidget(row, 6, nullcombo);
QSpinBox *altspinner = new QSpinBox(_fields);
altspinner->setRange(1, 999);
altspinner->setPrefix(tr("Column "));
if (! mf.isEmpty())
altspinner->setValue(mf.columnAlt());
_fields->setCellWidget(row, 7, altspinner);
QComboBox *altnullcombo = new QComboBox(_fields);
altnullcombo->addItems(CSVMapField::ifNullList(TRUE));
if (! mf.isEmpty())
altnullcombo->setCurrentIndex(mf.ifNullActionAlt());
_fields->setCellWidget(row, 8, altnullcombo);
_fields->setItem(row, 9, new QTableWidgetItem(mf.valueAlt()));
RowController *control = new RowController(_fields, row, colspinner);
control->setAction(actcombo);
control->setColumn(colspinner);
control->setIfNull(nullcombo);
control->setAltColumn(altspinner);
control->setAltIfNull(altnullcombo);
control->setAltValue(_fields->item(row, 9));
control->finishSetup();
}
}
else
{
_selectedMap = QString::null;
_table->setTitle(tr("Table: "));
_table->setEnabled(FALSE);
}
}
else
_msghandler->message(QtCriticalMsg, tr("No Database"),
tr("Could not get the database connection."));
}
示例8: createSpinBoxes
void Window::createSpinBoxes() {
/// \brief spinBoxesGroup
///
/// spinBoxesGroup is used to contains spinBox.
///
spinBoxesGroup = new QGroupBox(tr("Spinboxes"));
QLabel *integerLabel =
new QLabel(tr("Enter a value between %1 and %2:").arg(0).arg(1000));
QSpinBox *integerSpinBox = new QSpinBox;
integerSpinBox->setRange(-20, 20);
integerSpinBox->setSingleStep(1);
integerSpinBox->setValue(0);
QLabel *zoomLabel =
new QLabel(tr("Enter a zoom value between %1 and %2:").arg(0).arg(1000));
QSpinBox *zoomSpinBox = new QSpinBox;
zoomSpinBox->setRange(0, 1000);
zoomSpinBox->setSingleStep(10);
zoomSpinBox->setSuffix("%"); ///< a suffix
zoomSpinBox->setSpecialValueText(tr("Automatic"));
zoomSpinBox->setValue(100);
QLabel *priceLabel =
new QLabel(tr("Enter a price between %1 and %2:").arg(0).arg(999));
QSpinBox *priceSpinBox = new QSpinBox;
priceSpinBox->setRange(0, 999);
priceSpinBox->setPrefix("$");
priceSpinBox->setValue(99);
QLabel *hexLabel = new QLabel(tr("Enter a value between %1 and %2:")
.arg('-' + QString::number(31, 16))
.arg(QString::number(31, 16)));
QSpinBox *hexSpinBox = new QSpinBox;
hexSpinBox->setRange(-31, 31);
hexSpinBox->setSingleStep(1);
hexSpinBox->setDisplayIntegerBase(16);
groupSeparatorSpinBox = new QSpinBox;
groupSeparatorSpinBox->setRange(-9999999, 9999999);
groupSeparatorSpinBox->setValue(1000);
groupSeparatorSpinBox->setGroupSeparatorShown(true);
QCheckBox *groupSeparatorChkBox = new QCheckBox;
groupSeparatorChkBox->setText(tr("Show group separator"));
groupSeparatorChkBox->setChecked(true);
connect(groupSeparatorChkBox, &QCheckBox::toggled, groupSeparatorSpinBox,
&QSpinBox::setGroupSeparatorShown);
QVBoxLayout *spinBoxLayout = new QVBoxLayout;
spinBoxLayout->addWidget(integerLabel);
spinBoxLayout->addWidget(integerSpinBox);
spinBoxLayout->addWidget(zoomLabel);
spinBoxLayout->addWidget(zoomSpinBox);
spinBoxLayout->addWidget(priceLabel);
spinBoxLayout->addWidget(priceSpinBox);
spinBoxLayout->addWidget(hexLabel);
spinBoxLayout->addWidget(hexSpinBox);
spinBoxLayout->addWidget(groupSeparatorChkBox);
spinBoxLayout->addWidget(groupSeparatorSpinBox);
spinBoxesGroup->setLayout(spinBoxLayout);
}