python - QtDesigner - 在 Windows 7 下缺少功能?

标签 python c++ qt qt-designer qt-signals

我目前正在使用 QtDesigner 进行 Python 编程。在底部的信号和插槽下,您可以添加新信号。我想在菜单栏中添加一个点。 “退出”,如果它被激活,它应该关闭主窗口。

看起来像

actionQuit --Signal-- MainWindow close()

在 Ubuntu 12.04 下,我可以选择 activated() 作为信号。 windows版下没有activated()<Signals> 下?

是我做错了什么还是这只是 Windows 版本特有的?

最佳答案

我不确定你从哪里得到activated的想法,但人们应该使用来自 QAction 的触发信号:

void QAction::triggered(bool checked = false) [signal]

This signal is emitted when an action is activated by the user; for example, when the user clicks a menu option, toolbar button, or presses an action's shortcut key combination, or when trigger() was called. Notably, it is not emitted when setChecked() or toggle() is called.

If the action is checkable, checked is true if the action is checked, or false if the action is unchecked.

由于您没有提供更多信息,无论您使用 PySide 还是 PyQt,我都会为此提供规范的 Qt 单行代码,您可以轻松迁移到您钟爱的 python Qt 包装器:

connect(quitAct, SIGNAL(triggered()), this, SLOT(close()));

关于python - QtDesigner - 在 Windows 7 下缺少功能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23851067/

相关文章:

python - 如何一次快速设置 Django 模型的所有实例的字段?

python - "ImportError: No module named"错误似乎与我的代码无关

python - 使用 Python 的文本文件生成器

c++ - 我是否正确使用了 Grand Central Dispatch?

qt - 如何在 OpenGL 中使用顶点缓冲区对象和顶点数组?

c++ - 这是可变成员的问题 - QMUTEX 作为私有(private)成员吗?

python - 如何在Python中将PID写入文件?

c++ - 在 Mac OS X 10.6 上使用 clang 2.8 编译 C++ 代码时如何解决丢失的符号问题?

c++ - 你能判断一个 C++ 项目以前是否已经在 Eclipse 中构建了吗?

c++ - QtSerialPort 有不可用的数据,仅在 Windows 8 下出现段错误