error: passing 'const QVector' as 'this' argument of 'void QVector::ap

sdhgood 2015-09-14 11:18:42
QVector<QTime> Time;
double hh = line.mid(15,2).toDouble();
double mm = line.mid(17,2).toDouble();
double ss = line.mid(19,2).toDouble();
double mss = line.mid(22,3).toDouble();
QTime tt (int(hh),int(mm),int(ss),int(mss));
Time.append(tt);//出错
F:\work\zhidong\cpuplot\cpustat.cpp:59: error: passing 'const QVector<QTime>' as 'this' argument of 'void QVector<T>::append(const T&) [with T = QTime]' discards qualifiers [-fpermissive]
Time.append(tt);
^
F:\cpustat.cpp:59: error: invalid user-defined conversion from 'QTime(int, int, int, int)' to 'const QTime&' [-fpermissive]
是什么原因?
...全文
310 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
sdhgood 2015-09-24
  • 打赏
  • 举报
回复
原因是成员函数加了const了,我在成员函数里更改了成员变量,导致的,多谢你们,I LOVE YOU.
赵4老师 2015-09-14
  • 打赏
  • 举报
回复
不要纠结各种常量了,这个世界上唯一不变的就是变化。用API WriteProcessMemory还能修改正运行的其它进程的内存里面的所谓常量呢!
jiqiang01234 2015-09-14
  • 打赏
  • 举报
回复
你确定定义的时候没有const?

3,882

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 其它技术问题
社区管理员
  • 其它技术问题社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧