本文整理汇总了C++中QDateTime::fromTime_t方法的典型用法代码示例。如果您正苦于以下问题:C++ QDateTime::fromTime_t方法的具体用法?C++ QDateTime::fromTime_t怎么用?C++ QDateTime::fromTime_t使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDateTime
的用法示例。
在下文中一共展示了QDateTime::fromTime_t方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: New
int Indications::New(int id_pok_old, QString value_home)
{
int id_new = -1;
int date_old = -1, id_ListApart=-1;
QString str;
QStringList column, value;
QSqlQuery query;
// найдём дату текущих показаний
str = "SELECT date_pokazanie, id_list_app_usluga FROM pokazanie WHERE id_pokazanie=%1";
str = str.arg(id_pok_old);
if (query.exec(str)){
if (query.next()){
date_old = query.value(0).toInt();
id_ListApart = query.value(1).toInt();
}else{
qDebug() << "not record" << "575af8aa8da14fec062ce2bc5ef9e1e8 " << str;
}
} else{
qDebug()<<query.lastError();
}
QDateTime time;
time = time.fromTime_t(date_old);
time = time.addMonths(1);
DateOfUnixFormat date(time.date());
//Проверим на существование показаний на след месяц
str = "SELECT id_pokazanie FROM pokazanie "
"WHERE date_pokazanie=%1 AND id_list_app_usluga=%2";
str = str.arg(date.Second())
.arg(QString::number(id_ListApart));
QString id_pok_var;
BD::SelectFromTable(str,&id_pok_var);
if(id_pok_var == ""){//если нет записей
//добавим новое показание на след месяц
column.clear();
column<<"id_list_app_usluga"<<"date_pokazanie"<<"pokazanie_home"<<"pokazanie_end";
value.append(QString::number(id_ListApart));
value.append(QString::number(date.Second()));
value.append(value_home);
value.append(QString::number(0));
if (BD::add("pokazanie",column,value).number() != 0){
return -1;
}
}else{//иначе
//Обновим запись
BD::UpdateTable("pokazanie","pokazanie_home",value_home,"id_pokazanie",id_pok_var);
return id_pok_var.toInt();
}
return id_new;
}
示例2: getWall
void MainWindow::getWall(QString id)
{
curWall = id;
curOffset = 0;
getPostCount = 5;
qDebug() << " GETWALL in C++ emited " << id;
QQmlContext* context = rootContext();
postModel = new PostModel();
//postModel->addPost();
// GET PHOTO OF GROUP
QUrl cur("https://api.vk.com/method/groups.getById");
QUrlQuery queryn;
queryn.addQueryItem("v","5.2");
queryn.addQueryItem("access_token",Token);
queryn.addQueryItem("group_id",id);
cur.setQuery(queryn);
QByteArray answern = GET(cur);
QVariantList Listn = JSON::parse(answern).toMap().first().toList();
curn = Listn[0].toMap();
QUrl current("https://api.vk.com/method/wall.get");
QUrlQuery query;
query.addQueryItem("v","5.2");
query.addQueryItem("access_token",Token);
query.addQueryItem("owner_id","-"+id);
query.addQueryItem("offset",QString::number(curOffset));
query.addQueryItem("count",QString::number(getPostCount));
query.addQueryItem("filter","all");
current.setQuery(query);
QByteArray answer = GET(current);
//qDebug() << answer << " GET " ;
QVariantList List = JSON::parse(answer).toMap().value("response").toMap().value("items").toList(); // parse to list of objects Audio
for (int i=0; i<List.size(); i++)
{
QVariantMap current = List[i].toMap();
QDateTime date;
QDateTime dateNew = date.fromTime_t(current.value("date").toInt());
QStringList imgList;
QStringList audList;
QStringList vidList;
QVariantList attachments = current.value("attachments").toList();
//qDebug() << " ATTACH " << attachments[0].toMap().value("photo");
if (attachments.size()>0){
for (int k=0; k<attachments.size(); k++)
{
QVariantMap cur = attachments[k].toMap();
if (cur.value("type").toString() == "audio")
{
qDebug() << "Audio" << cur.value("audio").toMap().value("title").toString();
audList.append(cur.value("audio").toMap().value("title").toString());
}
if (cur.value("type").toString() == "photo")
{
qDebug() << "Photo" << cur.value("photo").toMap().value("photo_"+photoSize).toString();
imgList.append(cur.value("photo").toMap().value("photo_"+photoSize).toString());
//imgMod.addImage(Image(cur.value("photo").toMap().value("photo_130").toString(),cur.value("photo").toMap().value("id").toString(), cur.value("photo").toMap().value("photo_604").toString()));
}
if (cur.value("type").toString() == "video")
{
qDebug() << "Video" << cur.value("video").toMap().value("photo_"+photoSize).toString();
vidList.append(cur.value("video").toMap().value("photo_"+photoSize).toString());
}
}
}
qDebug() << " VIDEO MODEL " << vidList;
postModel->addPost(Post(
current.value("id").toString(),
current.value("text").toString(),
dateNew.toString(Qt::ISODate),
current.value("likes").toString(),
current.value("reposts").toString(),
current.value("comments").toString(),
current.value("type").toString(),
curn.value("photo_50").toString(),
curn.value("name").toString(),
imgList,
audList,
//.........这里部分代码省略.........
示例3: morePosts
void MainWindow::morePosts(){
qDebug() << " MORE POSTS in C++ emited " << curWall;
QQmlContext* context = rootContext();
//PostModel* tmpPostModel = new PostModel();
QUrl current("https://api.vk.com/method/wall.get");
QUrlQuery query;
query.addQueryItem("v","5.2");
query.addQueryItem("access_token",Token);
query.addQueryItem("owner_id","-"+curWall);
query.addQueryItem("offset",QString::number(curOffset));
query.addQueryItem("count",QString::number(getPostCount));
query.addQueryItem("filter","all");
current.setQuery(query);
QByteArray answer = GET(current);
QVariantList List = JSON::parse(answer).toMap().value("response").toMap().value("items").toList(); // parse to list of objects Audio
for (int i=0; i<List.size(); i++)
{
QVariantMap current = List[i].toMap();
QDateTime date;
QDateTime dateNew = date.fromTime_t(current.value("date").toInt());
QStringList imgList;
QStringList audList;
QStringList vidList;
QVariantList attachments = current.value("attachments").toList();
if (attachments.size()>0){
for (int k=0; k<attachments.size(); k++)
{
QVariantMap cur = attachments[k].toMap();
if (cur.value("type").toString() == "audio")
{
qDebug() << "Audio" << cur.value("audio").toMap().value("title").toString();
audList.append(cur.value("audio").toMap().value("title").toString());
}
if (cur.value("type").toString() == "photo")
{
qDebug() << "Photo" << cur.value("photo").toMap().value("photo_130").toString();
imgList.append(cur.value("photo").toMap().value("photo_130").toString());
//imgMod.addImage(Image(cur.value("photo").toMap().value("photo_130").toString(),cur.value("photo").toMap().value("id").toString(), cur.value("photo").toMap().value("photo_604").toString()));
}
if (cur.value("type").toString() == "video")
{
qDebug() << "Video" << cur.value("video").toMap().value("photo_130").toString();
vidList.append(cur.value("video").toMap().value("photo_130").toString());
}
}
}
postModel->addPost(Post(
current.value("id").toString(),
current.value("text").toString(),
dateNew.toString(Qt::ISODate),
current.value("likes").toString(),
current.value("reposts").toString(),
current.value("comments").toString(),
current.value("type").toString(),
curn.value("photo_50").toString(),
curn.value("name").toString(),
imgList,
audList,
vidList
)
);
}
curOffset+= getPostCount;
}