函数代码
#include <QList>
#include <QTime>
#include <QPointF>
typedef QPair<QPointF, QString> PointInfo;
typedef QList<PointInfo> RowPoint;
typedef QList<RowPoint> TablePoint;
TablePoint GenerateRandomData(int nColumnNum, int nRowNum, int nMaxValue)
{
const int MAX_VALUE = 10;
TablePoint tablePoint;
qsrand(static_cast<uint>(QTime(0, 0, 0).secsTo(QTime::currentTime())));
for (int i = 0; i != nColumnNum; ++i)
{
RowPoint rowPoint;
qreal yValue(0);
qreal xValue(0);
for (int j = 0; j != nRowNum; ++j)
{
xValue = j +
static_cast<qreal>(qrand()) /
static_cast<qreal>(RAND_MAX) *
static_cast<qreal>(MAX_VALUE) /
static_cast<qreal>(nRowNum);
yValue = yValue +
static_cast<qreal>(qrand() % nMaxValue) /
static_cast<qreal>(nRowNum);
QPointF point(xValue, yValue);
QString strLabel = "Slice" + QString::number(i) + ":" + QString::number(j);
rowPoint << PointInfo(point, strLabel);
}
tablePoint << rowPoint;
}
return tablePoint;
}