c++ - 如何在 Qt 的第二个窗口中设置 UI 小部件?
问题描述
我正在尝试通过Qt在登录(LoginWindow)之后出现的第二个窗口中动态设置文件(或字符串)的QList。第二个窗口是 QDialog。如何与 LsWindow(第二个窗口)的 UI 进行交互?我已经尝试过在 LsWindow.h 中使用 setUi() 函数,但它没有运行。
void LoginWindow::on_loginButton_clicked(){
// testing login
this->close(); // close login window
QStringList strList; //construct string list
strList.push_back("A");
strList.push_back("B");
QListWidget* l; // creating a widget
l->addItems(strList);
LsWindow* ls = new LsWindow(this);
ls->show();
//ls.ui.listWidget = l; (??)
ls->exec();
}
//LsWindow class implementation
class LsWindow : public QDialog
{
Q_OBJECT
public:
LsWindow(QWidget *parent = Q_NULLPTR);
~LsWindow();
private:
Ui::LsWindow ui;
};
解决方案
推荐阅读
- php - 将 php 数组作为对话流响应发送
- javascript - 如何在附近的输入文本框中显示值
- javascript - 试图理解 VSCode API 中的 Thennables。这些是等效的打字稿代码片段吗?
- html - CSS中的背景颜色在表格中遍历
- node.js - 使用 axios 响应原生 api 调用
- python - 在熊猫数据框中将 12 小时时间转换为 24 小时时间
- reactjs - 在我的 React 应用程序中,为什么没有执行这个 Redux reducer?
- c# - 将 Lambda 表达式传递给方法 C#
- android-studio - Flutter 无法解码 json 数据
- asp.net - 在 Blazor wasm 中自动将身份 Cookie 附加到 HTTP 客户端