本文整理汇总了C++中QSpinBox::value方法的典型用法代码示例。如果您正苦于以下问题:C++ QSpinBox::value方法的具体用法?C++ QSpinBox::value怎么用?C++ QSpinBox::value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSpinBox
的用法示例。
在下文中一共展示了QSpinBox::value方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: plotWorkspaces
/**
* Replots the currently loaded workspaces.
*/
void DataComparison::plotWorkspaces()
{
int globalSpecIndex = m_uiForm.sbSpectrum->value();
int maxGlobalSpecIndex = 0;
int numRows = m_uiForm.twCurrentData->rowCount();
for(int row = 0; row < numRows; row++)
{
// Get workspace
QString workspaceName = m_uiForm.twCurrentData->item(row, WORKSPACE_NAME)->text();
MatrixWorkspace_const_sptr workspace =
AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(workspaceName.toStdString());
int numSpec = static_cast<int>(workspace->getNumberHistograms());
// Calculate spectrum number
QSpinBox *specOffsetSpin = dynamic_cast<QSpinBox *>(m_uiForm.twCurrentData->cellWidget(row, SPEC_OFFSET));
int specOffset = specOffsetSpin->value();
int specIndex = globalSpecIndex - specOffset;
g_log.debug() << "Spectrum index for workspace " << workspaceName.toStdString()
<< " is " << specIndex << ", with offset " << specOffset << std::endl;
// See if this workspace extends the reach of the global spectrum selector
int maxGlobalSpecIndexForWs = numSpec + specOffset - 1;
if(maxGlobalSpecIndexForWs > maxGlobalSpecIndex)
maxGlobalSpecIndex = maxGlobalSpecIndexForWs;
// Check the spectrum index is in range
if(specIndex >= numSpec || specIndex < 0)
{
g_log.debug() << "Workspace " << workspaceName.toStdString()
<< ", spectrum index out of range." << std::endl;;
// Give "n/a" in current spectrum display
m_uiForm.twCurrentData->item(row, CURRENT_SPEC)->setText(tr("n/a"));
// Detech the curve from the plot
if(m_curves.contains(workspaceName))
m_curves[workspaceName]->attach(NULL);
continue;
}
// Update current spectrum display
m_uiForm.twCurrentData->item(row, CURRENT_SPEC)->setText(tr(QString::number(specIndex)));
// Create the curve data
const bool logScale(false), distribution(false);
QwtWorkspaceSpectrumData wsData(*workspace, static_cast<int>(specIndex), logScale, distribution);
// Detach the old curve from the plot if it exists
if(m_curves.contains(workspaceName))
m_curves[workspaceName]->attach(NULL);
QComboBox *colourSelector = dynamic_cast<QComboBox *>(m_uiForm.twCurrentData->cellWidget(row, COLOUR));
QColor curveColour = colourSelector->itemData(colourSelector->currentIndex()).value<QColor>();
// Create a new curve and attach it to the plot
auto curve = boost::make_shared<QwtPlotCurve>();
curve->setData(wsData);
curve->setPen(curveColour);
curve->attach(m_plot);
m_curves[workspaceName] = curve;
}
// Plot the diff
plotDiffWorkspace();
// Update the plot
m_plot->replot();
// Set the max value for global spectrum spin box
m_uiForm.sbSpectrum->setMaximum(maxGlobalSpecIndex);
m_uiForm.sbSpectrum->setSuffix(" / " + QString::number(maxGlobalSpecIndex));
}
示例2: QWidget
SpotMapperWindow::SpotMapperWindow(DeltaViewer* dv, int gw, int gh, int gd, int texSize, QWidget* parent)
: QWidget(parent)
{
textureSize = texSize;
globalWidth = gw;
globalHeight = gh;
globalDepth = gd;
sectionNo = gd / 2; // default to the middle slice
currentNuclearPerimeter = -1;
deltaViewer = dv;
x_origin = y_origin = 0; // then the
backgroundImage = 0;
// Make the relevant widgets..
plotter = new PerimeterPlotter(textureSize, this);
connect(plotter, SIGNAL(mousePos(int, int)), this, SLOT(newMousePos(int, int)) );
// The following are elements that are used to control the mapping process
checksBox = new QHBoxLayout(); // insert this layout into the appropriate position lower down
QLabel* repLabel = new QLabel("Repulse", this);
QDoubleSpinBox* repBox = new QDoubleSpinBox(this);
repBox->setRange(1, 100);
repBox->setValue(20);
QLabel* difLabel = new QLabel("Spread", this);
QDoubleSpinBox* diffuserSelector = new QDoubleSpinBox(this);
diffuserSelector->setRange(1, 100);
diffuserSelector->setValue(20);
QLabel* ssLabel = new QLabel("Step size", this);
QDoubleSpinBox* stepSizeSelector = new QDoubleSpinBox(this);
stepSizeSelector->setRange(1, 100);
stepSizeSelector->setValue(20);
QLabel* mfLabel = new QLabel("Min force", this);
QDoubleSpinBox* minForceSelector = new QDoubleSpinBox(this);
minForceSelector->setRange(0.01, 0.99);
minForceSelector->setSingleStep(0.01);
QLabel* sNoLabel = new QLabel("Max step no.", this);
QSpinBox* stepNumberSelector = new QSpinBox(this);
stepNumberSelector->setRange(1, 500);
stepNumberSelector->setValue(200);
spotMapper = new SpotMapper(stepNumberSelector->value(), stepSizeSelector->value(), diffuserSelector->value(), minForceSelector->value(), repBox->value());
// and make the set of connections I need to make sure that everything is kept up to date:
connect(stepNumberSelector, SIGNAL(valueChanged(int)), spotMapper, SLOT(setMaxSteps(int)) );
connect(stepSizeSelector, SIGNAL(valueChanged(double)), spotMapper, SLOT(setStepSize(double)) );
connect(diffuserSelector, SIGNAL(valueChanged(double)), spotMapper, SLOT(setSigma(double)) );
connect(minForceSelector, SIGNAL(valueChanged(double)), spotMapper, SLOT(setLimit(double)) );
connect(repBox, SIGNAL(valueChanged(double)), spotMapper, SLOT(setRepSigma(double)) );
/// some labels and a margin input for the nearest neighbour mapper
QLabel* nnLabel = new QLabel("Nearest Neighbor", this);
QLabel* nnMarginLabel = new QLabel("Margin", this);
QSpinBox* nnMargin = new QSpinBox(this);
nnMargin->setRange(10, 200);
nnMargin->setValue(60);
nnMapper = new NearestNeighborMapper(nnMargin->value());
connect(nnMargin, SIGNAL(valueChanged(int)), nnMapper, SLOT(setMargin(int)) );
QPushButton* nnMapButton = new QPushButton("Map", this);
connect(nnMapButton, SIGNAL(clicked()), this, SLOT(mapAllByNeighbor()) );
QPushButton* nnMapOneButton = new QPushButton("Map One", this);
connect(nnMapOneButton, SIGNAL(clicked()), this, SLOT(mapOneByNeighbor()) );
QLabel* maxPerimeterLabel = new QLabel("Perimeter max D", this);
QSpinBox* maxPerimeterD = new QSpinBox(this);
maxPerimeterD->setRange(10, 200);
maxPerimeterD->setValue(30);
spotPerimeterMapper = new SpotPerimeterMapper(maxPerimeterD->value());
connect(maxPerimeterD, SIGNAL(valueChanged(int)), spotPerimeterMapper, SLOT(setMaxDistance(int)) );
QPushButton* mapPerimeterButton = new QPushButton("Map Perimeter", this);
connect(mapPerimeterButton, SIGNAL(clicked()), this, SLOT(mapPerimeter()) );
QPushButton* makeCellsButton = new QPushButton("Make Cells", this);
connect(makeCellsButton, SIGNAL(clicked()), this, SLOT(makeCells()) );
QLabel* nucleusLabel = new QLabel("Selected nucleus", this);
selectedPerimeterLabel = new QLabel("----", this);
QLabel* bLabel = new QLabel("Blob", this);
blobSelector = new QSpinBox(this);
blobSelector->setRange(0, 0);
connect(blobSelector, SIGNAL(valueChanged(int)), this, SLOT(setBlob(int)) );
selBlobLabel = new QLabel("----, ----", this);
mouse_X_label = new QLabel("-----");
mouse_Y_label = new QLabel("-----");
QLabel* scaleLabel = new QLabel("Scale", this);
QDoubleSpinBox* scaleBox = new QDoubleSpinBox(this);
scaleBox->setRange(0.1, 10.0);
scaleBox->setSingleStep(0.1);
scaleBox->setValue(1.0);
//.........这里部分代码省略.........
示例3: cyc
void ChimeryMainWindow::cyc()
{
// Get info
cycs = cycNum->value();
QGridLayout * lay = (QGridLayout *) centralWidget()->layout();
// Delete all times in list (we recompute them in this loop)
while(!times->isEmpty())
delete times->takeFirst();
// Init stuff
if(gogogo)
{
delete gogogo;
gogogo = NULL;
}
if(gapL)
{
delete gapL;
gapL = NULL;
}
int cycle;
QDateTime Tstart = QDateTime(QDate::currentDate(), cycStart->time());
QDateTime Tend = QDateTime(Tstart);
QDateTime * insert;
QLinkedList<QPushButton *> * cycButtons_old = cycButtons;
QLinkedList<QPushButton *> * cycButtons_new = new QLinkedList<QPushButton *>();
QLinkedList<QSpinBox *> * cycGaps_old = cycGaps;
QLinkedList<QSpinBox *> * cycGaps_new = new QLinkedList<QSpinBox *>();
QPushButton * cycB;
QSpinBox * cycGap;
// Build widgets for cycles
for(cycle = 0; cycle < cycs; cycle++)
{
if(!cycGaps_old->isEmpty() && cycle < (cycs - 1))
{
cycGap = cycGaps_old->takeFirst();
cycGaps_new->append(cycGap);
}
else if(cycle < (cycs - 1))
{
cycGap = new QSpinBox(centralWidget());
cycGap->setRange(5, 90);
cycGap->setValue(20);
cycGap->setSingleStep(5);
lay->addWidget(cycGap, 2+cycle, 2);
QObject::connect(cycGap, SIGNAL(valueChanged(int)), this, SLOT(cyc()), Qt::QueuedConnection);
cycGaps_new->append(cycGap);
}
Tend = Tstart.addSecs(cycDur->value() * 60);
if(!cycButtons_old->isEmpty())
{
cycB = cycButtons_old->takeFirst();
cycB->setText(Tstart.toString("hh:mm") + "-" + Tend.toString("hh:mm"));
cycButtons_new->append(cycB);
}
else
{
cycB = new QPushButton(Tstart.toString("hh:mm") + "-" + Tend.toString("hh:mm"), centralWidget());
cycB->setCheckable(true);
cycB->setChecked(true);
lay->addWidget(cycB, 2+cycle, 0);
QObject::connect(cycB, SIGNAL(clicked()), this, SLOT(cyc()), Qt::QueuedConnection);
cycButtons_new->append(cycB);
}
if(cycle == 0 && cycs > 1)
{
gapL = new QLabel("Gap:", centralWidget());
lay->addWidget(gapL, 2, 1, Qt::AlignRight);
}
if(cycB->isChecked())
{
insert = new QDateTime(Tstart);
times->append(insert);
insert = new QDateTime(Tend);
times->append(insert);
}
if(cycle < cycs - 1)
Tstart = Tstart.addSecs((cycDur->value() + cycGap->value()) * 60);
}
示例4: retrieveValue
bool QgsAttributeEditor::retrieveValue( QWidget *widget, QgsVectorLayer *vl, int idx, QVariant &value )
{
if ( !widget )
return false;
const QgsField &theField = vl->pendingFields()[idx];
QgsVectorLayer::EditType editType = vl->editType( idx );
bool modified = false;
QString text;
QSettings settings;
QString nullValue = settings.value( "qgis/nullValue", "NULL" ).toString();
QLineEdit *le = qobject_cast<QLineEdit *>( widget );
if ( le )
{
text = le->text();
modified = le->isModified();
if ( text == nullValue )
{
text = QString::null;
}
}
QTextEdit *te = qobject_cast<QTextEdit *>( widget );
if ( te )
{
text = te->toHtml();
modified = te->document()->isModified();
if ( text == nullValue )
{
text = QString::null;
}
}
QPlainTextEdit *pte = qobject_cast<QPlainTextEdit *>( widget );
if ( pte )
{
text = pte->toPlainText();
modified = pte->document()->isModified();
if ( text == nullValue )
{
text = QString::null;
}
}
QComboBox *cb = qobject_cast<QComboBox *>( widget );
if ( cb )
{
if ( editType == QgsVectorLayer::UniqueValues ||
editType == QgsVectorLayer::ValueMap ||
editType == QgsVectorLayer::Classification ||
editType == QgsVectorLayer::ValueRelation )
{
text = cb->itemData( cb->currentIndex() ).toString();
if ( text == nullValue )
{
text = QString::null;
}
}
else
{
text = cb->currentText();
}
modified = true;
}
QListWidget *lw = qobject_cast<QListWidget *>( widget );
if ( lw )
{
if ( editType == QgsVectorLayer::ValueRelation )
{
text = '{';
for ( int i = 0, n = 0; i < lw->count(); i++ )
{
if ( lw->item( i )->checkState() == Qt::Checked )
{
if ( n > 0 )
{
text.append( ',' );
}
text.append( lw->item( i )->data( Qt::UserRole ).toString() );
n++;
}
}
text.append( '}' );
}
else
{
text = QString::null;
}
modified = true;
}
QSpinBox *sb = qobject_cast<QSpinBox *>( widget );
if ( sb )
{
text = QString::number( sb->value() );
}
//.........这里部分代码省略.........
示例5: setModelData
void qtractorMidiEventItemDelegate::setModelData ( QWidget *pEditor,
QAbstractItemModel *pModel, const QModelIndex& index ) const
{
const qtractorMidiEventListModel *pListModel
= static_cast<const qtractorMidiEventListModel *> (pModel);
qtractorMidiEvent *pEvent = pListModel->eventOfIndex(index);
if (pEvent == NULL)
return;
qtractorMidiEditor *pMidiEditor = pListModel->editor();
if (pMidiEditor == NULL)
return;
#ifdef CONFIG_DEBUG
qDebug("qtractorMidiEventItemDelegate::setModelData(%p, %p, %d, %d)",
pEditor, pListModel, index.row(), index.column());
#endif
qtractorTimeScale *pTimeScale = pMidiEditor->timeScale();
qtractorMidiEditCommand *pEditCommand
= new qtractorMidiEditCommand(pMidiEditor->midiClip(),
tr("edit %1").arg(pListModel->headerData(
index.column(), Qt::Horizontal, Qt::DisplayRole)
.toString().toLower()));
switch (index.column()) {
case 0: // Time.
{
qtractorTimeSpinBox *pTimeSpinBox
= qobject_cast<qtractorTimeSpinBox *> (pEditor);
if (pTimeSpinBox) {
unsigned long iTime
= pTimeScale->tickFromFrame(pTimeSpinBox->valueFromText());
if (iTime > pMidiEditor->timeOffset())
iTime -= pMidiEditor->timeOffset();
else
iTime = 0;
unsigned long iDuration = 0;
if (pEvent->type() == qtractorMidiEvent::NOTEON)
iDuration = pEvent->duration();
pEditCommand->resizeEventTime(pEvent, iTime, iDuration);
}
break;
}
case 2: // Name.
{
QComboBox *pComboBox = qobject_cast<QComboBox *> (pEditor);
if (pComboBox) {
const int iNote = pComboBox->currentIndex();
const unsigned long iTime = pEvent->time();
pEditCommand->moveEvent(pEvent, iNote, iTime);
}
break;
}
case 3: // Value.
{
QSpinBox *pSpinBox = qobject_cast<QSpinBox *> (pEditor);
if (pSpinBox) {
const int iValue = pSpinBox->value();
pEditCommand->resizeEventValue(pEvent, iValue);
}
break;
}
case 4: // Duration/Data.
{
qtractorTimeSpinBox *pTimeSpinBox
= qobject_cast<qtractorTimeSpinBox *> (pEditor);
if (pTimeSpinBox) {
const unsigned long iTime = pEvent->time();
const unsigned long iDuration
= pTimeScale->tickFromFrame(pTimeSpinBox->value());
pEditCommand->resizeEventTime(pEvent, iTime, iDuration);
}
break;
}
default:
break;
}
// Do it.
pMidiEditor->commands()->exec(pEditCommand);
}
示例6: QString
void WidgetIOProperties::createIOProperties()
{
ui->mainLayout->setColumnMinimumWidth(0, 150);
ui->optionLayout->setColumnMinimumWidth(0, 150);
QString lang = Utils::GetLocale();
QString rsc = QString(":/doc/%1/io_doc.json").arg(lang);
QFile f(rsc);
if (!f.open(QIODevice::ReadOnly | QIODevice::Text))
{
QMessageBox::warning(this, tr("Error"), tr("Failed to load IO documentation from %1").arg(rsc));
return;
}
QJsonParseError jerr;
QJsonDocument jdoc = QJsonDocument::fromJson(f.readAll(), &jerr);
if (jerr.error != QJsonParseError::NoError ||
!jdoc.isObject())
{
QMessageBox::warning(this, tr("Error"), tr("Failed to parse JSON IO documentation from %1").arg(rsc));
return;
}
QString iotype = QString::fromUtf8(params["type"].c_str());
QJsonObject jobj = jdoc.object();
for (auto it = jobj.begin();it != jobj.end();it++)
jobj.insert(it.key().toLower(), it.value());
QJsonObject jobjAlias;
if (!jobj.contains(iotype))
{
//Search in aliases
bool aliasfound = false;
for (auto it = jobj.constBegin();it != jobj.constEnd();it++)
{
QJsonObject o = it.value().toObject();
QJsonArray jalias = o["alias"].toArray();
for (int i = 0;i < jalias.size();i++)
{
if (jalias.at(i).toString() == iotype)
{
aliasfound = true;
jobjAlias = o;
}
}
}
if (!aliasfound)
{
QMessageBox::warning(this, tr("Error"), tr("IO type %1 is not found in %2").arg(iotype).arg(rsc));
return;
}
}
QJsonObject jioobj;
if (jobjAlias.isEmpty())
jioobj = jobj[iotype].toObject();
else
jioobj = jobjAlias;
ui->labelTitle->setText(iotype);
ui->labelDesc->setText(jioobj["description"].toString());
int rowMain = 0, rowOption = 0;
QJsonArray jparams = jioobj["parameters"].toArray();
for (int i = 0;i < jparams.size();i++)
{
QJsonObject jparam = jparams[i].toObject();
QGridLayout *layout = jparam["mandatory"].toString() == "true"?ui->mainLayout:ui->optionLayout;
int row = jparam["mandatory"].toBool()?rowMain:rowOption;
QLabel *title = new QLabel(jparam["name"].toString());
layout->addWidget(title, row, 0);
QPushButton *revert = new QPushButton();
revert->setIcon(QIcon(":/img/document-revert.png"));
revert->setToolTip(tr("Revert modification"));
layout->addWidget(revert, row, 1);
hider.hide(revert);
QString pvalue;
string prop = jparam["name"].toString().toUtf8().constData();
if (params.Exists(prop))
pvalue = QString::fromUtf8(params[prop].c_str());
else
pvalue = jparam["default"].toString();
if (jparam["type"].toString() == "string")
{
QLineEdit *w = new QLineEdit();
w->setEnabled(jparam["readonly"].toString() != "true" && editable);
w->setText(pvalue);
layout->addWidget(w, row, 2);
UiObject uiObject;
uiObject.type = UiObjectType::LineEdit;
uiObject.lineEdit = w;
uiObjectMap[prop] = uiObject;
//.........这里部分代码省略.........
示例7: updateCLI
// Update associated CLI widget based on QWidget / QObject data
void QtWidgetObject::updateCLI()
{
// Check treeGuiWidget_ pointer first
if (treeGuiWidget_ == NULL)
{
printf("Internal Error: treeGuiWidget_ pointer is NULL in updateCLI().\n");
return;
}
// Now, check widget type to see what we do
if (treeGuiWidget_->type() == TreeGuiWidget::RadioGroupWidget)
{
QButtonGroup *butgroup = static_cast<QButtonGroup*>(qObject_);
if (!butgroup) printf("Critical Error: Couldn't cast stored qObject_ pointer into QButtonGroup.\n");
else treeGuiWidget_->setProperty(TreeGuiWidgetEvent::ValueProperty, butgroup->checkedId());
}
else if (treeGuiWidget_->type() == TreeGuiWidget::CheckWidget)
{
QCheckBox *check = static_cast<QCheckBox*>(qWidget_);
if (!check) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QCheckBox.\n");
else treeGuiWidget_->setProperty(TreeGuiWidgetEvent::ValueProperty, check->isChecked());
}
else if (treeGuiWidget_->type() == TreeGuiWidget::ComboWidget)
{
QComboBox* combo = static_cast<QComboBox*>(qWidget_);
if (!combo) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QComboBox.\n");
else treeGuiWidget_->setProperty(TreeGuiWidgetEvent::ValueProperty, combo->currentIndex()+1);
}
else if (treeGuiWidget_->type() == TreeGuiWidget::DoubleSpinWidget)
{
QDoubleSpinBox* spin = static_cast<QDoubleSpinBox*>(qWidget_);
if (!spin) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QDoubleSpinBox.\n");
else treeGuiWidget_->setProperty(TreeGuiWidgetEvent::ValueProperty, spin->value());
}
else if (treeGuiWidget_->type() == TreeGuiWidget::EditWidget)
{
QLineEdit *edit = static_cast<QLineEdit*>(qWidget_);
if (!edit) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QTextEdit.\n");
else treeGuiWidget_->setProperty(TreeGuiWidgetEvent::ValueProperty, qPrintable(edit->text()));
}
else if (treeGuiWidget_->type() == TreeGuiWidget::IntegerSpinWidget)
{
QSpinBox *spin = static_cast<QSpinBox*>(qWidget_);
if (!spin) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QSpinBox.\n");
else treeGuiWidget_->setProperty(TreeGuiWidgetEvent::ValueProperty, spin->value());
}
else if (treeGuiWidget_->type() == TreeGuiWidget::LabelWidget)
{
QLabel *label = static_cast<QLabel*>(qWidget_);
if (!label) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QLabel.\n");
}
else if (treeGuiWidget_->type() == TreeGuiWidget::RadioButtonWidget)
{
QRadioButton *button = static_cast<QRadioButton*>(qWidget_);
if (!button) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QRadioButton.\n");
else treeGuiWidget_->setProperty(TreeGuiWidgetEvent::ValueProperty, button->isChecked());
}
else if (treeGuiWidget_->type() == TreeGuiWidget::TabWidget)
{
QTabWidget *tabs = static_cast<QTabWidget*>(qWidget_);
if (!tabs) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QTabWidget.\n");
else treeGuiWidget_->setProperty(TreeGuiWidgetEvent::ValueProperty, tabs->currentIndex()+1);
}
else if (treeGuiWidget_->type() == TreeGuiWidget::StackWidget)
{
QStackedWidget *stack = static_cast<QStackedWidget*>(qWidget_);
if (!stack) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QStackedWidget.\n");
else treeGuiWidget_->setProperty(TreeGuiWidgetEvent::ValueProperty, stack->currentIndex()+1);
}
else printf("Internal Error: No handler written to update CLI controls of this type (%s).\n", TreeGuiWidget::widgetType(treeGuiWidget_->type()));
}
示例8: slotSpinBoxValueChanged
void PropertiesEditorItem::slotSpinBoxValueChanged()
{
QSpinBox *spinBox = qobject_cast<QSpinBox*>(mWidget.data());
mProperty.write(mObject.data(), spinBox->value());
}
示例9: visualRect
/* FIXME make this less of a hack. */
QRect TestCalendarWidget::visualRect(QString const &item) const
{
TestWidgetsLog() << item << "my geometry is" << geometry();
QRect ret;
QAbstractItemView *view = q->findChild<QAbstractItemView*>();
QtUiTest::ListWidget *calendarView
= qtuitest_cast<QtUiTest::ListWidget*>(view);
if (!calendarView) {
return ret;
}
ret = calendarView->visualRect(item);
if (!ret.isNull()) {
ret.moveTopLeft( q->mapFromGlobal( view->mapToGlobal(ret.topLeft()) ) );
TestWidgetsLog() << item << "is a visible day at" << ret;
return ret;
}
QToolButton *yearButton = 0;
QToolButton *monthButton = 0;
QSpinBox *yearSpin = q->findChild<QSpinBox*>();
QMenu *monthMenu = 0;
QList<QToolButton*> blist = q->findChildren<QToolButton*>();
foreach(QToolButton *b, blist) {
if (!monthButton && (monthMenu = b->menu())) {
monthButton = b;
}
if (!b->menu()) {
yearButton = b;
}
}
TestWidgetsLog() << "monthButton" << monthButton << "yearButton" << yearButton;
TestWidgetsLog() << "item" << item << "monthMenu" << monthMenu;
if (yearButton && yearButton->isVisible() && yearButton->text() == item) {
QPoint p = q->mapFromGlobal( yearButton->mapToGlobal(QPoint(yearButton->width()+5, yearButton->height()/2)) );
ret = QRect(p.x() - 2, p.y() - 2, 5, 5);
TestWidgetsLog() << "click near yearbutton";
} else if (yearSpin && yearSpin->isVisible() && yearSpin->value() == item.toInt()) {
TestWidgetsLog() << "confirm spinbox";
QPoint p = q->mapFromGlobal( yearSpin->mapToGlobal(QPoint(yearSpin->width()+5, yearSpin->height()/2)) );
ret = QRect(p.x() - 2, p.y() - 2, 5, 5);
} else if (monthButton && monthButton->isVisible() && monthButton->text() == item) {
QPoint p = q->mapFromGlobal( monthButton->mapToGlobal(QPoint(-5, monthButton->height()/2)) );
ret = QRect(p.x() - 2, p.y() - 2, 5, 5);
TestWidgetsLog() << "click near monthbutton";
} else if (monthMenu && monthMenu->isVisible()
&& qtuitest_cast<QtUiTest::ListWidget*>(monthMenu)
&& qtuitest_cast<QtUiTest::ListWidget*>(monthMenu)->list().contains(item)) {
ret = qtuitest_cast<QtUiTest::ListWidget*>(monthMenu)->visualRect(item);
ret.moveTopLeft( q->mapFromGlobal( monthMenu->mapToGlobal(ret.topLeft()) ) );
TestWidgetsLog() << "click on monthmenu";
} else {
do {
QStringList items = list();
if (items.contains(item)) {
ret = QRect(-1, -1, 1, 1);
ret.moveTopLeft( q->mapFromGlobal(QPoint(-1,-1)) );
break;
}
foreach (QString s, items) {
if (!s.startsWith(GetListRegExp)) continue;
QRegExp re(s.mid(GetListRegExp.length()));
if (re.exactMatch(item)) {
ret = QRect(-1, -1, 1, 1);
ret.moveTopLeft( q->mapFromGlobal(QPoint(-1,-1)) );
break;
}
}
if (!ret.isNull()) break;
} while(0);
}
TestWidgetsLog() << "returning rect" << ret;
return ret;
}
示例10: operator
void RandomImgOp::operator()(const imagein::Image*, const std::map<const imagein::Image*, std::string>&) {
QDialog* dialog = new QDialog(qApp->activeWindow());
dialog->setWindowTitle(qApp->translate("RandomImgOp", "Parameters"));
dialog->setMinimumWidth(180);
QFormLayout* layout = new QFormLayout(dialog);
QGroupBox* radioGroup = new QGroupBox(qApp->translate("RandomImgOp", "Image type"), dialog);
QRadioButton* intButton = new QRadioButton(qApp->translate("RandomImgOp", "8-bit integer"));
QRadioButton* floatButton = new QRadioButton(qApp->translate("RandomImgOp", "Floating point"));
QHBoxLayout* radioLayout = new QHBoxLayout(radioGroup);
radioLayout->addWidget(intButton);
radioLayout->addWidget(floatButton);
intButton->setChecked(true);
layout->insertRow(0, radioGroup);
QSpinBox* widthBox = new QSpinBox(dialog);
widthBox->setRange(0, 65536);
widthBox->setValue(512);
layout->insertRow(1, qApp->translate("RandomImgOp", "Width : "), widthBox);
QSpinBox* heightBox = new QSpinBox(dialog);
heightBox->setRange(0, 65536);
heightBox->setValue(512);
layout->insertRow(2, qApp->translate("RandomImgOp", "Height : "), heightBox);
QSpinBox* channelBox = new QSpinBox(dialog);
channelBox->setRange(1, 4);
channelBox->setValue(3);
layout->insertRow(3, qApp->translate("RandomImgOp", "Number of channels : "), channelBox);
QWidget* intRangeWidget = new QWidget(dialog);
QHBoxLayout* intRangeLayout = new QHBoxLayout(intRangeWidget);
QSpinBox* intMinBox = new QSpinBox(dialog);
QSpinBox* intMaxBox = new QSpinBox(dialog);
intMinBox->setRange(0, 255);
intMaxBox->setRange(0, 255);
intMinBox->setValue(0);
intMaxBox->setValue(255);
intRangeLayout->addWidget(new QLabel(qApp->translate("RandomImgOp", "Range : ")));
intRangeLayout->addWidget(intMinBox);
intRangeLayout->addWidget(new QLabel(qApp->translate("RandomImgOp", " to ")));
intRangeLayout->addWidget(intMaxBox);
layout->insertRow(4, intRangeWidget);
QWidget* floatRangeWidget = new QWidget(dialog);
QHBoxLayout* floatRangeLayout = new QHBoxLayout(floatRangeWidget);
QDoubleSpinBox* floatMinBox = new QDoubleSpinBox(dialog);
QDoubleSpinBox* floatMaxBox = new QDoubleSpinBox(dialog);
floatMinBox->setValue(0.0);
floatMaxBox->setValue(1.0);
floatMinBox->setRange(-65536, 65536);
floatMaxBox->setRange(-65536, 65536);
floatRangeLayout->addWidget(new QLabel(qApp->translate("RandomImgOp", "Range : ")));
floatRangeLayout->addWidget(floatMinBox);
floatRangeLayout->addWidget(new QLabel(qApp->translate("RandomImgOp", " to ")));
floatRangeLayout->addWidget(floatMaxBox);
layout->insertRow(5, floatRangeWidget);
floatRangeWidget->hide();
layout->setSizeConstraint(QLayout::SetFixedSize);
QObject::connect(intButton, SIGNAL(toggled(bool)), intRangeWidget, SLOT(setVisible(bool)));
QObject::connect(floatButton, SIGNAL(toggled(bool)), floatRangeWidget, SLOT(setVisible(bool)));
QPushButton *okButton = new QPushButton(qApp->translate("Operations", "Validate"), dialog);
okButton->setDefault(true);
layout->addWidget(okButton);
QObject::connect(okButton, SIGNAL(clicked()), dialog, SLOT(accept()));
QDialog::DialogCode code = static_cast<QDialog::DialogCode>(dialog->exec());
if(code!=QDialog::Accepted) {
return;
}
if(intButton->isChecked()) {
Image* resImg = new Image(widthBox->value(), heightBox->value(), channelBox->value());
RandomLib::Random random;
for(unsigned int c = 0; c < resImg->getNbChannels(); ++c) {
for(unsigned int j = 0; j < resImg->getHeight(); ++j) {
for(unsigned int i = 0; i < resImg->getWidth(); ++i) {
Image::depth_t value = random.IntegerC<Image::depth_t>(intMinBox->value(), intMaxBox->value());
// Image::depth_t value = 256. * (rand() / (RAND_MAX + 1.));;
resImg->setPixel(i, j, c, value);
}
}
}
this->outImage(resImg, qApp->translate("Operations", "Random image").toStdString());
}
else if(floatButton->isChecked()) {
Image_t<double>* resImg = new Image_t<double>(widthBox->value(), heightBox->value(), channelBox->value());
RandomLib::Random random;
for(unsigned int c = 0; c < resImg->getNbChannels(); ++c) {
for(unsigned int j = 0; j < resImg->getHeight(); ++j) {
for(unsigned int i = 0; i < resImg->getWidth(); ++i) {
double min = floatMinBox->value();
double max = floatMaxBox->value();
//.........这里部分代码省略.........
示例11: setModelData
void SceneTableUi::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const
{
QVariant value;
switch (index.column())
{
case QTV_DELAY1:
case QTV_DELAY2:
{
QSpinBox *spinBox = static_cast<QSpinBox*>(editor);
spinBox->interpretText();
value = spinBox->value();
}
break;
case QTV_SCENE1:
case QTV_SCENE2:
case QTV_TRANSITION:
{
QComboBox *comboBox = static_cast<QComboBox*>(editor);
value = comboBox->currentText();
}
break;
}
model->setData(index, value, Qt::EditRole);
ObsAction* action = 0;
if (ObsActions)
{
action = (*ObsActions)[index.row()+1];
}
if (action)
{
bool changed = false;
switch (index.column())
{
case QTV_DELAY1:
if (action->GetDelay1() != value.toInt())
{
action->SetDelay1(value.toInt());
changed = true;
}
break;
case QTV_DELAY2:
if (action->GetDelay2() != value.toInt())
{
action->SetDelay2(value.toInt());
changed = true;
}
break;
case QTV_SCENE1:
if (QString::compare(action->GetScene1Name(), value.toString()))
{
action->SetScene1(ObsSwitcher->GetScene(value.toString()));
changed = true;
if (value.toString().isEmpty() || value.toString().isNull())
{
QModelIndex index = model->index(index.row(), 4, QModelIndex());
model->setData(index, value, Qt::EditRole);
}
}
break;
case QTV_SCENE2:
if (QString::compare(action->GetScene2Name(), value.toString()))
{
action->SetScene2(ObsSwitcher->GetScene(value.toString()));
changed = true;
}
break;
case QTV_TRANSITION:
if (QString::compare(action->GetTransitionName(), value.toString()))
{
action->SetTransition(ObsSwitcher->GetTransition(value.toString()));
changed = true;
}
break;
}
if (changed)
{
ObsSwitcher->SaveActions();
}
}
}
示例12: reg
//.........这里部分代码省略.........
break;
default:
module->conf_.bank_operation = MesytecMadc32ModuleConfig::boConnected;
break;
}
}
if(_name == "test_pulser_mode") {
switch(cbb->currentIndex()) {
case 0:
module->conf_.test_pulser_mode = MesytecMadc32ModuleConfig::tpOff;
break;
case 1:
module->conf_.test_pulser_mode = MesytecMadc32ModuleConfig::tpAmp0;
break;
case 2:
module->conf_.test_pulser_mode = MesytecMadc32ModuleConfig::tpAmpLow;
break;
case 3:
module->conf_.test_pulser_mode = MesytecMadc32ModuleConfig::tpAmpHigh;
break;
case 4:
module->conf_.test_pulser_mode = MesytecMadc32ModuleConfig::tpToggle;
break;
default:
module->conf_.test_pulser_mode = MesytecMadc32ModuleConfig::tpOff;
break;
}
}
//QMessageBox::information(this,"uiInput","You changed the combobox "+_name);
}
QSpinBox* sb = findChild<QSpinBox*>(_name);
if(sb != 0)
{
if(_name == "irq_level") module->conf_.irq_level = sb->value();
if(_name == "irq_vector"){
module->conf_.irq_vector = sb->value();
}
if(_name == "irq_threshold"){
module->conf_.irq_threshold = sb->value();
}
if(_name == "base_addr_register"){
module->conf_.base_addr_register = sb->value();
}
if(_name == "time_stamp_divisor"){
module->conf_.time_stamp_divisor = sb->value();
}
if(_name == "max_transfer_data"){
module->conf_.max_transfer_data= sb->value();
}
if(_name == "rc_module_id_read"){
module->conf_.rc_module_id_read = sb->value();
}
if(_name == "rc_module_id_write"){
module->conf_.rc_module_id_write = sb->value();
}
if(_name.startsWith("hold_delay_")) {
int ch = _name.right(1).toInt();
module->conf_.hold_delay[ch] = sb->value();
}
if(_name.startsWith("hold_width_")) {
int ch = _name.right(1).toInt();
module->conf_.hold_width[ch] = sb->value();
}
if(_name.startsWith("thresholds")) {
QRegExp reg("[0-9]{1,2}");
reg.indexIn(_name);
示例13: setModelData
void FormDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index) const
{
const CGeorgesFormProxyModel * mp = dynamic_cast<const CGeorgesFormProxyModel *>(index.model());
const CGeorgesFormModel * m = dynamic_cast<const CGeorgesFormModel *>(mp->sourceModel());
const NLGEORGES::UType *type = m->getItem(mp->mapToSource(index))->getFormElm()->getType();
int numDefinitions = type->getNumDefinition();
if (numDefinitions)
{
QComboBox *comboBox = static_cast<QComboBox*>(editor);
QString value = comboBox->currentText();
QString oldValue = index.model()->data(index, Qt::DisplayRole).toString();
if (value == oldValue)
{
// nothing's changed
}
else
{
nldebug(QString("setModelData from %1 to %2")
.arg(oldValue).arg(value).toUtf8().constData());
model->setData(index, value, Qt::EditRole);
}
}
else
{
switch (type->getType())
{
case NLGEORGES::UType::UnsignedInt:
case NLGEORGES::UType::SignedInt:
{
QSpinBox *spinBox = static_cast<QSpinBox*>(editor);
int value = spinBox->value();
QString oldValue = index.model()->data(index, Qt::DisplayRole).toString();
if (QString("%1").arg(value) == oldValue)
{
// nothing's changed
}
else
{
nldebug(QString("setModelData from %1 to %2")
.arg(oldValue).arg(value).toUtf8().constData());
model->setData(index, value, Qt::EditRole);
}
break;
}
case NLGEORGES::UType::Double:
{
QDoubleSpinBox *spinBox = static_cast<QDoubleSpinBox*>(editor);
double value = spinBox->value();
QString oldValue = index.model()->data(index, Qt::DisplayRole).toString();
if (QString("%1").arg(value) == oldValue)
{
// nothing's changed
}
else
{
nldebug(QString("setModelData from %1 to %2")
.arg(oldValue).arg(value).toUtf8().constData());
model->setData(index, value, Qt::EditRole);
}
break;
}
case NLGEORGES::UType::Color:
{
break; // TODO
}
default: // UType::String
{
QLineEdit *textEdit = static_cast<QLineEdit*>(editor);
QString value = textEdit->text();
QString oldValue = index.model()->data(index, Qt::DisplayRole).toString();
if (value == oldValue)
{
// nothing's changed
}
else
{
nldebug(QString("setModelData from %1 to %2")
.arg(oldValue).arg(value).toUtf8().constData());
model->setData(index, value, Qt::EditRole);
}
break;
}
}
}
}
示例14: setModelData
void PointItemDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
{
QSpinBox *spinBox = qobject_cast<QSpinBox *>(editor);
model->setData(index, spinBox->value());
}
示例15: setModelData
void SpinBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index) const
{
QSpinBox *box = static_cast<QSpinBox*>(editor);
model->setData( index, box->value(), Qt::EditRole );
}