c++ - 如何解析 "invalid operands of types ' const char [ ]' and ' const char *' to binary ' operator +' "

标签 c++ qt c-str

我使用 Qt Creator 和这段代码:

string execpath = "";
execpath += (QCoreApplication::applicationDirPath()).toStdString();
WinExec("ffmpeg -f dshow -t 32 -i audio=\"virtual-audio-capturer\" -y "+(execpath.c_str())+"\\sound.mp3", SW_HIDE); // Loopback captured in sound.mp3

在第 3 行生成此问题:

invalid operands of types 'const char [60]' and 'const char*' to binary 'operator+'

如何解决?

最佳答案

你会想要这样的东西:

execpath += (QCoreApplication::applicationDirPath()).toStdString();
std::string cmd = "ffmpeg -f dshow -t 32 -i audio=\"virtual-audio-capturer\" -y "
WinExec((cmd +execpath +"\\sound.mp3").c_str(), SW_HIDE);

关于c++ - 如何解析 "invalid operands of types ' const char [ ]' and ' const char *' to binary ' operator +' ",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21957516/

相关文章:

c++ - SFML - 尝试从 vector 绘制 Sprite 时程序崩溃

c++ - 在保留顺序的同时将float转换为int64_t

c++ - 错误 : could not convert '<brace-enclosed initializer list>()' from '<brace-enclosed initializer list>' to 'struct'

qt - 如何在Qt qtreeview中的treecolumn之前添加列

qt - 如何正确删除 QGraphicsItem?

c++ - std::string::c_str & 空终止

c# - 如何从 C# 调用 C++ 类

linux - 我应该如何在 Qt 中编写窗口管理器?

c++ - Boost.Program_Options:为什么 options_description_easy_init::operator() 没有 std::string 的重载?

c++ - 在 C++ 中对来自全局函数的结构成员使用方法