本文整理汇总了C++中PlotSettings::offset方法的典型用法代码示例。如果您正苦于以下问题:C++ PlotSettings::offset方法的具体用法?C++ PlotSettings::offset怎么用?C++ PlotSettings::offset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlotSettings
的用法示例。
在下文中一共展示了PlotSettings::offset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupSourceTable
void PlotSettingsDialog::setupSourceTable(const QStringList &dataSeriesNames, const PlotSettings &preset, bool offsetsEditable)
{
ui->sourceTable->setColumnCount(COLCOUNT);
QTableWidgetItem *sourceNameColHeader = new QTableWidgetItem(tr("Data Series Name"));
sourceNameColHeader->setToolTip(tr("The name of the data series."));
ui->sourceTable->setHorizontalHeaderItem(SOURCENAMECOL, sourceNameColHeader);
QTableWidgetItem *offsetColHeader = new QTableWidgetItem(tr("Offset"));
offsetColHeader->setToolTip(tr("The offset in milliseconds.\n\n"
"This value is added to each timestamp\n"
"of the respective data series.\n"
"You can use this for example to adjust for\n"
"time lags in the transmission of signals."));
ui->sourceTable->setHorizontalHeaderItem(OFFSETCOL, offsetColHeader);
QTableWidgetItem *scaleColHeader = new QTableWidgetItem(tr("Scale Type"));
if (offsetsEditable) {
scaleColHeader->setToolTip(tr("The <i>default</i> type of scale to be used for the data series."));
} else {
scaleColHeader->setToolTip(tr("The type of scale to be used for the data series."));
}
ui->sourceTable->setHorizontalHeaderItem(SCALECOL, scaleColHeader);
QHeaderView *hHeader = ui->sourceTable->horizontalHeader();
hHeader->setDefaultAlignment(Qt::AlignLeft);
hHeader->setResizeMode(SOURCENAMECOL, QHeaderView::Stretch);
hHeader->setResizeMode(OFFSETCOL, QHeaderView::ResizeToContents);
hHeader->setResizeMode(SCALECOL, QHeaderView::ResizeToContents);
hHeader->setMinimumSectionSize(120);
QHeaderView *vHeader = ui->sourceTable->verticalHeader();
vHeader->setVisible(false);
foreach (QString sourceName, dataSeriesNames) {
int row = ui->sourceTable->rowCount();
ui->sourceTable->setRowCount(row + 1);
QTableWidgetItem *sourceItem = new QTableWidgetItem(sourceName);
// the item showing the data series name should not be editable
sourceItem->setFlags(sourceItem->flags() & ~Qt::ItemIsEditable);
ui->sourceTable->setItem(row, SOURCENAMECOL, sourceItem);
QDoubleSpinBox *offsetSpinner = new QDoubleSpinBox(ui->sourceTable);
offsetSpinner->setAlignment(Qt::AlignRight);
// helps to set the min/max before you set the value ;)
offsetSpinner->setMinimum(0.0);
offsetSpinner->setMaximum(std::numeric_limits<double>::max());
offsetSpinner->setDecimals(qRound(qLn(OFFSETDIVISOR)/qLn(10)));
offsetSpinner->setValue(preset.offset(sourceName)/OFFSETDIVISOR);
offsetSpinner->setEnabled(offsetsEditable);
ui->sourceTable->setCellWidget(row, OFFSETCOL, offsetSpinner);
if (preset.scaleType(sourceName) == PlotSettings::NOT_SCALABLE) {
QTableWidgetItem *scaleItem = new QTableWidgetItem(tr("n/a"));
scaleItem->setFlags(scaleItem->flags() & ~Qt::ItemIsEditable);
ui->sourceTable->setItem(row, SCALECOL, scaleItem);
} else {
QComboBox *scaleCombo = new QComboBox();
scaleCombo->addItems(PlotSettings::scaleTypeNames);
scaleCombo->setCurrentIndex(preset.scaleType(sourceName));
ui->sourceTable->setCellWidget(row, SCALECOL, scaleCombo);
}
}