DeleteWindow *new_win = new DeleteWindow();; new_win->getpath(thepath); QString thepath="/"; void DeleteWindow::getpath(QString inpath){path=inpath;} 现在path增多,需要用vector存放,给出修改代码
时间: 2024-01-22 08:02:29 浏览: 82
GetPath_Demo.rar_DEMO_vc2005 wince
如果需要用 vector 存储多个路径,可以将 path 从 QString 类型改为 std::vector<std::string> 类型,并相应地修改 getpath() 函数和类的定义。具体实现如下:
```
#include <vector>
#include <string>
class DeleteWindow {
public:
void getpaths(std::vector<std::string> inpaths) { paths = inpaths; }
private:
std::vector<std::string> paths;
};
// 使用示例:
DeleteWindow* new_win = new DeleteWindow();
std::vector<std::string> thepaths = { "/", "/home", "/var" };
new_win->getpaths(thepaths);
```
这样就可以用 vector 存储多个路径了。
阅读全文