QDialog:如何使用问号(?)按钮? [英] QDialog: how to use question mark (?) button?

查看:150
本文介绍了QDialog:如何使用问号(?)按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

默认情况下,QDialog 窗口的右上角有一个问号按钮.当我按下它时,鼠标光标变为禁止"光标,并且似乎没有其他任何事情发生.

By default, QDialog windows have a question mark pushbutton in the upper-right corner. When I press it, the mouse cursor is changed to the 'Forbidden' cursor, and nothing else seems to happen.

虽然有很多信息来自那些想要删除问号的人(at 最少 三个 SO 线程专门用于主题),QDialog 的文档没有任何关于如何实际使用它.

While there is lots of information generated from those who want to remove the question mark (at least three SO threads are devoted to the topic), the documentation for QDialog doesn't have anything about how to actually use it.

如何让我的应用程序在点击问号时显示信息?例如,如何从按钮获取 clicked 信号?更好的是,此按钮记录在哪里?

How do I get my application to display information when the question mark is clicked? E.g., how do I get the clicked signal from the button? Better yet, where is this button documented?

推荐答案

它不是 Qt 记录的按钮.您可以通过捕获事件和检查事件类型来检测这一点:

It is not a button documented by Qt. You can detect this by catching events and checking event type:

http://qt-project.org/doc/qt-5/qevent.html#Type-enum

有不同的类型,如 QEvent::EnterWhatsThisMode QEvent::WhatsThisClicked 等等.我在主窗口中使用事件过滤器实现了与您正在寻找的类似的东西.

There are different types as QEvent::EnterWhatsThisMode QEvent::WhatsThisClicked and so on. I achieved something similar to what are you looking for using event filter in mainwindow.

if(event->type() == QEvent::EnterWhatsThisMode)
    qDebug() << "click";

当我点击 ? 按钮时,我看到了点击".

I saw "click" when I clicked on ? button.

这篇关于QDialog:如何使用问号(?)按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆