c++ - `QTreeView` 什么时候在 Mac 上发出激活信号?

标签 c++ qt

当您按 Return 键时,以下代码行在 Windows 上有效,但在 Mac 上无效。有谁知道为什么?

connect(qTreeView, SIGNAL(activated(const QModelIndex &)), this, SLOT(actJoin()));

当我查看它提到的 API 时

This signal is emitted when the item specified by index is activated by the user. How to activate items depends on the platform; e.g., by single- or double-clicking the item, or by pressing the Return or Enter key when the item is current.

是否还有其他方法可以在我缺少的 Mac 上激活?

最佳答案

CMD+O应该是激活的Mac版本,如图here

#ifdef Q_WS_MAC
        if (event->key() == Qt::Key_O && event->modifiers() & Qt::ControlModifier && currentIndex().isValid()) {
            emit activated(currentIndex());
            break;
        }

在 Mac 上按 Return 键不会激活它,它会进入编辑模式。

关于c++ - `QTreeView` 什么时候在 Mac 上发出激活信号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31650780/

相关文章:

c++ - 没有用于调用的匹配函数...继承的 C++ 类中缺少重载

php - 哪种性能更好 - 使用 php-qt 或使用 swig 为 c++ 编写自定义 php 扩展?

c++ - C++ 中的 for_each()

c++ - 使用键盘 : unintended side effects when pressing enter 将数据输入到 Qt GUI

c++ - 如何将 Qt 集成到现有的 C++ 项目中

c++ - 派生的 C++ 类如何通过基指针克隆自身?

c++ - 在 C++ 中释放 vector

c++ - 如何从 QString 中删除尾随空格?

c++ - QT 4.5.2,QTableView不可编辑

qt - 通过 QSerialPort 访问来自 Arduino 的串行数据时遇到问题