QFileDialog
只是系统对话框的包装器。这就是为什么在那里搜索没有用的原因QActions
。相反,如果您在 Windows 中运行程序,您可以使用 WIN API 来处理对话框。
这是一个简单的示例,其中一些文本被放置在文件名控件中并单击了“打开”按钮:
#define WAIT(A) while (!(A)) {}
HWND dialogHandle, button, edit, combo, comboEx;
WAIT(dialogHandle = FindWindow(NULL, L"Open"));
WAIT(button = FindWindowEx(dialogHandle, NULL, L"Button", L"&Open"));
WAIT(comboEx = FindWindowEx(dialogHandle, comboEx, L"ComboBoxEx32", NULL));
WAIT(combo = FindWindowEx(comboEx, combo, L"ComboBox", NULL));
WAIT(edit = FindWindowEx(combo, NULL, L"Edit", NULL));
char text[] = "arc.h";
SendMessageA(edit, WM_SETTEXT, 0, (LPARAM) text);
SendMessage(button, BM_CLICK, 0, 0);