在QLineEdit子类中未调用focusInEvent
focusInEvent not called in QLineEdit subclass
我有一个Qt/cpp代码,并显示子类QLineEdit
。当双击QLineEdit
时,focusInEvent
永远不会被调用(在Maya中启动)。
void myQLineEditClass::focusInEvent(QFocusEvent *e)
{
MGlobal::displayInfo(MQtUtil::toMString(QString().sprintf("HERE")));
QLineEdit::focusInEvent(e);
}
如果focusInEvent
存在于.h保护部分,则永远不会显示HERE。你知道如何获得focusInEvents吗?
尝试以下操作。有几次,当focusInEvent不起作用时,它对我有效。
void YourWidget::changeEvent(QEvent* event)
{
if (event->type() == QEvent::ActivationChange)
{
if (isActiveWindow())
{
// gaining the focus
}
else
{
// loosing the focus
}
}
// or whatever *parent* class call is
QWidget::changeEvent(event);
}
事件被编辑器小部件截获。参见QItemDelegate::createEditor
。返回的小部件将获得它。
该问题与QLineEdit位于另一个QGraphicsView中的QGraphicsView中的事实相关联。将QLineEdit带到更高级别的QGraphicsView使其工作
相关文章:
- 什么时候调用组成单元对象的析构函数
- 对RValue对象调用的LValue ref限定成员函数
- 为什么使用 "this" 指针调用派生成员函数?
- 函数调用中参数的顺序重要吗
- OpenGL - 在抛出"__gnu_cxx::recursive_init_error"实例后终止调用?
- 基于另一个成员参数将函数调用从类传递给它的一个成员
- 为什么我的C#代码在调用回C++COM直到Task时会暂停.等待/线程.加入
- 在c++类上调用void函数
- 为什么 std::unique 不调用 std::sort?
- 调用专用模板时出错"no matching function for call to [...]"
- 选择要调用的构造函数
- C++为什么尽管我调用了void函数,它却不起作用
- 构造函数正在调用一个使用当前类类型的函数
- 变量没有改变?通过向量的函数调用
- 没有为自己的结构调用列表推回方法
- 调用'begin(int [n])'没有匹配函数
- 什么时候调用析构函数
- 如何用参数值调用函数(仅在运行时已知)
- std::cout.imbue()多重调用
- 在QLineEdit子类中未调用focusInEvent