当前位置: 首页>>代码示例>>C++>>正文


C++ setData函数代码示例

本文整理汇总了C++中setData函数的典型用法代码示例。如果您正苦于以下问题:C++ setData函数的具体用法?C++ setData怎么用?C++ setData使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了setData函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setData

bool SelectionModel::setData(int row, const QVariant &value, const QByteArray &role) {
    return setData(index(row), value, m_roles.key(role));
}
开发者ID:marxoft,项目名称:tuxr,代码行数:3,代码来源:selectionmodel.cpp

示例2: setData

/*!
  Initialize data with an array of samples.
  \param samples Vector of points
*/
void QwtPlotSpectroCurve::setSamples( const QVector<QwtPoint3D> &samples )
{
    setData( new QwtPoint3DSeriesData( samples ) );
}
开发者ID:Abbath,项目名称:lbsim,代码行数:8,代码来源:qwt_plot_spectrocurve.cpp

示例3: setData

//--------------------------------Execute---------------------------------//
//this method performs the actions for the Return object, using the
//store as a parameter to access the inventory and alter accordingly
//it also uses the file stream to read in the information
//according to formatting specifications, setting it for this specified
//derived transaction class
bool Returnx::execute(ifstream& file, Store& st)
{
	int custIdx;
	file >> custIdx;
	Customer* cust = st.getCustomer(custIdx);
	//read the custtomer index and get the customer at that index
	//from the store, if the store doesn't have the customer at that
	//spot then the customer has not been created and we cannot do anything
	if (cust == NULL)
	{
		cout << "Invalid Customer ID. Transaction could not be executed.\n";
		//no need for clean up since Customer is still NULL
		return false;
	}
	else
	{
		char format;
		file >> format;
		//read in the format, the format is specified to only be DVDs
		if (format != 'D')
		{
			cout << "Invalid format. Transaction could not be executed.\n";
			//no need for clean up since Formaat is not dynamic
			return false;
		}
		else
		{
			char genre;
			file >> genre;
			//read in the genre and then use the stores movie factory
			//to create a temporary movie of this genre,
			//however, if the genre did not correspond to an appropriate
			//movie, return false
			Movie* tempMov = st.getMovieFact().createIt(genre);
			if (tempMov == NULL)
			{
				cout << "Invalid movie. Transaction could not be"
					<< "executed.\n";
				//no need for clean up since tempMov is still NULL
				return false;
			}
			else
			{
				//everything worked, now we try to set the data
				//from the format specifications of a return
				//movie, and if this didn't work, the movie was 
				//created so we must clean this up. otherwise, we try
				//to return the movie from the inventory
				if (!tempMov->readTrans(file))
				{
					delete tempMov;
					tempMov = NULL;
					return false;
				}
				else
				{
					if (!cust->returnMovie(tempMov))
					{
						cout << "Invalid movie. Transaction could not be "
							<< "executed.\n";
						delete tempMov;
						tempMov = NULL;

						return false;
					}
					else
					{
						Movie* mov;
						//use a movie locator and a movie return value
						//to try to return the movie from the stores
						//inventory, if the return couldn't occur
						//we must delete the temporary movie
						if (!st.getInventory().returnMovie(mov, tempMov))
						{
							//if we couldn't return we must clean up
							cout << "Invalid movie." <<
								"Transaction could not be "
								<< "executed.\n";
							delete tempMov;
							tempMov = NULL;

							return false;
						}
						else
						{
							//otherwise everything worked out perfectly
							//so the data is set and the customer
							//adds this transaction to his/her trans hist
							//and clean up our temp mov
							setData(cust, mov);
							//cust->returnMovie(mov);
							delete tempMov;
							tempMov = NULL;
							cust->addTransaction(this);
//.........这里部分代码省略.........
开发者ID:chrisadubois,项目名称:moviestore,代码行数:101,代码来源:returnx.cpp

示例4: setData

 //--------------------------------------------------------------------------
 void CClan::init( ClanData* pData )
 {
     setData(pData);
 }
开发者ID:dnjsflagh1,项目名称:code,代码行数:5,代码来源:CClan.cpp

示例5: i18n

uint NotificationsEngine::Notify(const QString &app_name, uint replaces_id,
                                 const QString &app_icon, const QString &summary, const QString &body,
                                 const QStringList &actions, const QVariantMap &hints, int timeout)
{
    uint id = 0;
    id = replaces_id ? replaces_id : m_nextId++;

    QString appname_str = app_name;
    if (appname_str.isEmpty()) {
        appname_str = i18n("Unknown Application");
    }

    if (timeout == -1) {
        const int AVERAGE_WORD_LENGTH = 6;
        const int WORD_PER_MINUTE = 250;
        int count = summary.length() + body.length();
        timeout = 60000 * count / AVERAGE_WORD_LENGTH / WORD_PER_MINUTE;

        // Add two seconds for the user to notice the notification, and ensure
        // it last at least five seconds, otherwise all the user see is a
        // flash
        timeout = 2000 + qMax(timeout, 3000);
    }

    const QString source = QString("notification %1").arg(id);
    if (replaces_id) {
        Plasma::DataContainer *container = containerForSource(source);
        if (container && container->data()["expireTimeout"].toInt() != timeout) {
            int timerId = m_sourceTimers.value(source);
            killTimer(timerId);
            m_sourceTimers.remove(source);
            m_timeouts.remove(timerId);
        }
    }

    Plasma::DataEngine::Data notificationData;
    notificationData.insert("id", QString::number(id));
    notificationData.insert("appName", appname_str);
    notificationData.insert("appIcon", app_icon);
    notificationData.insert("summary", summary);
    notificationData.insert("body", body);
    notificationData.insert("actions", actions);
    notificationData.insert("expireTimeout", timeout);

    QImage image;
    if (hints.contains("image_data")) {
        QDBusArgument arg = hints["image_data"].value<QDBusArgument>();
        image = decodeNotificationSpecImageHint(arg);
    } else if (hints.contains("image_path")) {
        QString path = findImageForSpecImagePath(hints["image_path"].toString());
        if (!path.isEmpty()) {
            image.load(path);
        }
    } else if (hints.contains("icon_data")) {
        // This hint was in use in version 1.0 of the spec but has been
        // replaced by "image_data" in version 1.1. We need to support it for
        // users of the 1.0 version of the spec.
        QDBusArgument arg = hints["icon_data"].value<QDBusArgument>();
        image = decodeNotificationSpecImageHint(arg);
    }
    notificationData.insert("image", image);

    if (hints.contains("urgency")) {
        notificationData.insert("urgency", hints["urgency"].toInt());
    }

    setData(source, notificationData );

    if (timeout) {
        int timerId = startTimer(timeout);
        m_sourceTimers.insert(source, timerId);
        m_timeouts.insert(timerId, source);
    }

    return id;
}
开发者ID:mgottschlag,项目名称:kwin-tiling,代码行数:76,代码来源:notificationsengine.cpp

示例6: dataSize


//.........这里部分代码省略.........
							double x0 = x, y0 = y;
							while(fabs(xr - xl)/step > 1e-15 && iter < points){
								x = 0.5*(xl + xr);
								y = parser.Eval();
								if (gsl_finite(y)){
									xr = x;
									x0 = x;
									y0 = y;
								} else
									xl = x;
								iter++;
							}
							d_from = x0;
							X[0] = x0;
							Y[0] = y0;
							step = (d_to - d_from)/(double)(lastButOne);
							break;
						}
					}
					if (!wellDefinedFunction){
						QMessageBox::critical(0, QObject::tr("QtiPlot"),
						QObject::tr("The function %1 is not defined in the specified interval!").arg(d_formulas[0]));
						free(X); free(Y);
						return false;
					}
				} else {
					X[0] = d_from;
					Y[0] = y;
				}
			} catch (MyParser::Pole) {}

			ScaleEngine *sc_engine = 0;
			if (plot())
				sc_engine = (ScaleEngine *)plot()->axisScaleEngine(xAxis());

			if (xLog10Scale || (d_from > 0 && d_to > 0 && sc_engine &&
				sc_engine->type() == ScaleTransformation::Log10)){
				step = log10(d_to/d_from)/(double)(points - 1);
				for (int i = 1; i < lastButOne; i++ ){
					x = d_from*pow(10, i*step);
					X[i] = x;
					try {
						Y[i] = parser.EvalRemoveSingularity(&x, false);
					} catch (MyParser::Pole){}
				}
			} else {
				for (int i = 1; i < lastButOne; i++ ){
					x += step;
					X[i] = x;
					try {
						Y[i] = parser.EvalRemoveSingularity(&x, false);
					} catch (MyParser::Pole){}
				}
			}
			//the last point might be outside the interval, therefore we calculate it separately at its precise value
			x = d_to;
			X[lastButOne] = x;
			try {
				Y[lastButOne] = parser.EvalRemoveSingularity(&x, false);
			} catch (MyParser::Pole){}
		} catch(mu::ParserError &e) {}
	} else if (d_function_type == Parametric || d_function_type == Polar) {
		QStringList aux = d_formulas;
		MyParser xparser;
		MyParser yparser;
		double par;
		if (d_function_type == Polar) {
			QString swap=aux[0];
			aux[0]="("+swap+")*cos("+aux[1]+")";
			aux[1]="("+swap+")*sin("+aux[1]+")";
		}

		try {
			QMapIterator<QString, double> i(d_constants);
			while (i.hasNext()){
				i.next();
				xparser.DefineConst(i.key().ascii(), i.value());
				yparser.DefineConst(i.key().ascii(), i.value());
			}

			xparser.DefineVar(d_variable.ascii(), &par);
			yparser.DefineVar(d_variable.ascii(), &par);
			xparser.SetExpr(aux[0].ascii());
			yparser.SetExpr(aux[1].ascii());
			par = d_from;
			for (int i = 0; i<points; i++ ){
				X[i] = xparser.Eval();
				Y[i] = yparser.Eval();
				par += step;
			}
		} catch(mu::ParserError &) {}
	}

	if (curveType() == QwtPlotCurve::Yfx)
		setData(X, Y, points);
	else
		setData(Y, X, points);
	free(X); free(Y);
	return true;
}
开发者ID:BackupTheBerlios,项目名称:qtiplot-svn,代码行数:101,代码来源:FunctionCurve.cpp

示例7: setSamples

/*!
  Assign a series of points

  setSamples() is just a wrapper for setData() without any additional
  value - beside that it is easier to find for the developer.

  \param data Data
  \warning The item takes ownership of the data object, deleting
           it when its not used anymore.
*/
void QwtPlotCurve::setSamples( QwtSeriesData<QPointF> *data )
{
    setData( data );
}
开发者ID:Au-Zone,项目名称:qwt,代码行数:14,代码来源:qwt_plot_curve.cpp

示例8: setData

/*!
  \brief Initialize the data by pointing to memory blocks which 
         are not managed by QwtPlotCurve.

  setRawSamples is provided for efficiency. 
  It is important to keep the pointers
  during the lifetime of the underlying QwtCPointerData class.

  \param xData pointer to x data
  \param yData pointer to y data
  \param size size of x and y

  \sa QwtCPointerData
*/
void QwtPlotCurve::setRawSamples( 
    const double *xData, const double *yData, int size )
{
    setData( new QwtCPointerData( xData, yData, size ) );
}
开发者ID:Au-Zone,项目名称:qwt,代码行数:19,代码来源:qwt_plot_curve.cpp

示例9: setData

PropertyItemInt::PropertyItemInt( QString name, const QVariant &value, PropertyItem *parent )
:PropertyItem(name,parent) {
 setData(value);


}
开发者ID:MassMessage,项目名称:qpropertygrid,代码行数:6,代码来源:TypeInt.cpp

示例10: setData

void
ModelWindow::setDirty()
{
    dirty = true;
    setData(false);
}
开发者ID:deanjunk,项目名称:GoldenCheetah,代码行数:6,代码来源:ModelWindow.cpp

示例11: setData

void Input::setRep(QMap<QString, QVariant> rep)
{
    setData(rep);
}
开发者ID:malikazoo,项目名称:codesample,代码行数:4,代码来源:input.cpp

示例12: setData

QxtSqlPackage& QxtSqlPackage::operator= (const QxtSqlPackage & other)
{
    setData(other.data());
    return *this;
}
开发者ID:01iv3r,项目名称:OpenPilot,代码行数:5,代码来源:qxtsqlpackage.cpp

示例13: setRawSamples

/*!
  Set data by copying x- and y-values from specified memory blocks.
  Contrary to setRawSamples(), this function makes a 'deep copy' of
  the data.

  \param xData pointer to x values
  \param yData pointer to y values
  \param size size of xData and yData

  \sa QwtPointArrayData
*/
void QwtPlotCurve::setSamples( 
    const double *xData, const double *yData, int size )
{
    setData( new QwtPointArrayData( xData, yData, size ) );
}
开发者ID:Au-Zone,项目名称:qwt,代码行数:16,代码来源:qwt_plot_curve.cpp

示例14: switch

int QHexEdit::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QScrollArea::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: currentAddressChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 1: currentSizeChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 2: dataChanged(); break;
        case 3: overwriteModeChanged((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 4: setAddressWidth((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 5: setAddressArea((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 6: setAsciiArea((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 7: setHighlighting((*reinterpret_cast< bool(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 8;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QByteArray*>(_v) = data(); break;
        case 1: *reinterpret_cast< int*>(_v) = addressOffset(); break;
        case 2: *reinterpret_cast< QColor*>(_v) = addressAreaColor(); break;
        case 3: *reinterpret_cast< QColor*>(_v) = highlightingColor(); break;
        case 4: *reinterpret_cast< QColor*>(_v) = selectionColor(); break;
        case 5: *reinterpret_cast< bool*>(_v) = overwriteMode(); break;
        case 6: *reinterpret_cast< bool*>(_v) = isReadOnly(); break;
        case 7: *reinterpret_cast< QFont*>(_v) = font(); break;
        }
        _id -= 8;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setData(*reinterpret_cast< QByteArray*>(_v)); break;
        case 1: setAddressOffset(*reinterpret_cast< int*>(_v)); break;
        case 2: setAddressAreaColor(*reinterpret_cast< QColor*>(_v)); break;
        case 3: setHighlightingColor(*reinterpret_cast< QColor*>(_v)); break;
        case 4: setSelectionColor(*reinterpret_cast< QColor*>(_v)); break;
        case 5: setOverwriteMode(*reinterpret_cast< bool*>(_v)); break;
        case 6: setReadOnly(*reinterpret_cast< bool*>(_v)); break;
        case 7: setFont(*reinterpret_cast< QFont*>(_v)); break;
        }
        _id -= 8;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 8;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
开发者ID:TigerSecurity,项目名称:PassiveNetwork,代码行数:62,代码来源:moc_qhexedit.cpp

示例15: remove

void DataCurve::loadData()
{
  Plot *plot = static_cast<Plot *>(this->plot());
  Graph *g = static_cast<Graph *>(plot->parent());
  if (!g)
    return;

  int xcol = d_table->colIndex(d_x_column);
  int ycol = d_table->colIndex(title().text());

  if (xcol < 0 || ycol < 0){
    remove();
    return;
  }

  int r = abs(d_end_row - d_start_row) + 1;
  QVarLengthArray<double> X(r), Y(r);
  int xColType = d_table->columnType(xcol);
  int yColType = d_table->columnType(ycol);

  QStringList xLabels, yLabels;// store text labels

//  int xAxis = QwtPlot::xBottom;
//  if (d_type == Graph::HorizontalBars)
//    xAxis = QwtPlot::yLeft;

  QTime time0;
  QDateTime date0;
  QString date_time_fmt = d_table->columnFormat(xcol);
  if (xColType == Table::Time){
    for (int i = d_start_row; i <= d_end_row; i++ ){
      QString xval=d_table->text(i,xcol);
      if (!xval.isEmpty()){
        time0 = QTime::fromString (xval, date_time_fmt);
        if (time0.isValid())
          break;
      }
    }
  } else if (xColType == Table::Date){
    for (int i = d_start_row; i <= d_end_row; i++ ){
      QString xval=d_table->text(i,xcol);
      if (!xval.isEmpty()){
        date0 = QDateTime::fromString (xval, date_time_fmt);
        if (date0.isValid())
          break;
      }
    }
  }

  int size = 0;
  for (int i = d_start_row; i <= d_end_row; i++ ){
    QString xval = d_table->text(i,xcol);
    QString yval = d_table->text(i,ycol);
    if (!xval.isEmpty() && !yval.isEmpty()){
      bool valid_data = true;
      if (xColType == Table::Text){
        xLabels << xval;
        X[size] = (double)(size + 1);
      } else if (xColType == Table::Time){
        QTime time = QTime::fromString (xval, date_time_fmt);
        if (time.isValid())
          X[size]= time0.msecsTo (time);
      } else if (xColType == Table::Date){
        QDateTime d = QDateTime::fromString (xval, date_time_fmt);
        if (d.isValid())
          X[size] = (double) date0.secsTo(d);
      } else
        X[size] = plot->locale().toDouble(xval, &valid_data);

      if (yColType == Table::Text){
        yLabels << yval;
        Y[size] = (double)(size + 1);
      } else
        Y[size] = plot->locale().toDouble(yval, &valid_data);

      if (valid_data)
        size++;
    }
  }

  X.resize(size);
  Y.resize(size);

  // The code for calculating the waterfall offsets, that is here in QtiPlot, has been moved up to
  // PlotCurve so that MantidCurve can access it as well.
  if (g->isWaterfallPlot())
  {
    // Calculate the offsets
    computeWaterfallOffsets();
  }
  // End re-jigged waterfall offset code

  if (!size){
    remove();
    return;
  } else {
    if (d_type == Graph::HorizontalBars){
      setData(Y.data(), X.data(), size);
      foreach(DataCurve *c, d_error_bars)
        c->setData(Y.data(), X.data(), size);
//.........这里部分代码省略.........
开发者ID:stothe2,项目名称:mantid,代码行数:101,代码来源:PlotCurve.cpp


注:本文中的setData函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。