错误:cannot convert 'QString' to 'const char*' for argument '1' to 'int system(const char*)'
来源:互联网 发布:王者荣耀模拟器mac版 编辑:程序博客网 时间:2024/04/28 20:32
system(str1);//
则:/home/qust/qt/time-build-desktop-Desktop_Qt_4_8_0_for_GCC__Qt_SDK____/../time/mainwindow.cpp:31: 错误:cannot convert 'QString' to 'const char*' for argument '1' to 'int system(const char*)'
修改:
QString str1 = "date -s 04/30/2012";
system(str1.toLatin1().data());//
QByteArray QString::toLatin1 () const
Returns a Latin-1 representation of the string as a QByteArray.
The returned byte array is undefined if the string contains non-Latin1 characters. Those characters may be suppressed or replaced with a question mark.
char * QByteArray::data ()
Returns a pointer to the data stored in the byte array. The pointer can be used to access and modify the bytes that compose the array. The data is '\0'-terminated, i.e. the number of bytes in the returned character string is size() + 1 for the '\0' terminator.
Example:
QByteArray ba("Hello world"); char *data = ba.data(); while (*data) { cout << "[" << *data << "]" << endl; ++data; }
- 错误:cannot convert 'QString' to 'const char*' for argument '1' to 'int system(const char*)'
- cannot convert from 'const int' to 'const char *'
- "QString" to "const char*"
- 【笔记】编译报错error: cannot convert ‘main(int, char**)::sockadrr*’ to ‘const sockaddr*’ for
- Cannot convert from 'const char [..]' to 'LPCTSTR'
- Cannot convert from 'const char [..]' to 'LPCTSTR'
- cannot convert wchar_t to const char*
- E2034 Cannot convert 'wchar_t *' to 'const char *'
- error C2664: 'atof' : cannot convert parameter 1 from 'int' to 'const char *'
- cannot convert parameter 1 from 'CString' to 'const char *'
- cannot convert parameter 1 from 'const char *' to 'LPCWSTR
- cannot convert parameter 1 from 'std::string' to 'const char *'
- LoadCursorA' : cannot convert parameter 2 from 'const int' to 'const char *
- cannot convert from 'const char [51]' to 'const CString'
- 错误1error C2664: 'CWnd::MessageBoxW' : cannot convert parameter 1 from 'const char [17]' to 'LPCTST
- VS2005下的 cannot convert parameter 1 from 'const char [5]' to 'LPCTSTR'错误解决
- VS2008编译错误, error C2664: cannot convert parameter 1 from 'const char [27]' to 'LPCT
- VC++ 出现错误:cannot convert from const char *' to 'LPCWSTR' 或者'const char [7]' to 'LPCWSTR' 的解决方法
- 个人收藏 如何从SAP中查找BADI
- android中的HandlerThread类的学习
- OLE 操作Excel 祥解
- AsyncTask的用法
- Objective-C 对URL进行URLEncode编码
- 错误:cannot convert 'QString' to 'const char*' for argument '1' to 'int system(const char*)'
- REUSE_ALV_GRID_DISPLAY 编辑数据
- 实现JavaBeans到XML的相互转换
- uboot传递内核参数全解析
- ABAP_OBJECTS
- DEMO_DYNPRO_SUBSCREENS
- 算法导论学习笔记(4)——利用链接法实现哈希表
- 选择屏幕 子屏幕
- 使用spring的hibernateTemplate的方法