Qt设置windows系统时间

  Qt设置windows系统时间网上的回答很多,但很少有一步到位的,一般会有8小时时差,下面给出直接解决代码:

  #include "windows.h"

  void Dialog::setTime()
  {
    SYSTEMTIME st;
    GetLocalTime(&st);//关键在这里
    st.wHour=ui->spinBox->value();
    st.wMinute=ui->spinBox_2->value();
    st.wSecond=ui->spinBox_3->value();
    SetLocalTime(&st);
  }

 

posted @ 2014-05-13 18:58  Bird-Man  阅读(1104)  评论(0编辑  收藏  举报