我正在寻找一些方法来为QGraphicsItem.
我知道我可以setToolTip用来设置工具提示的文本。现在我想要的是当鼠标悬停在QGraphicsItem对象的不同部分时动态更改文本。
我想做的是当我收到一个事件时QEvent::ToolTip,我会更改该事件处理程序中的工具提示文本。但是,我无法找到一个事件函数收到QEvent::ToolTip了QGraphicsItem。
或者是否有一些方法可以处理鼠标悬停 2 秒的事件。
我怎样才能做到?
在C ++中,我们可以使用“ *”获取指针的值,并使用“&”获取值的地址(指针)。但是当在无效指针上使用这些运算符时,我遇到了令人困惑的事情。
这是我的测试代码:
#include <iostream>
using namespace std;
class B
{
public:
B() { x = 10; }
int x;
int GetX() { return x; }
};
class A
{
public:
B* b;
A()
{
b = nullptr;
}
B* GetB() { return b; }
};
int main()
{
A * a = new A();
B ib = *a->GetB();
B * pb = &ib;
B * pb2 = a->GetB();
if (nullptr != pb2)
{
cout << "pb2 is not …Run Code Online (Sandbox Code Playgroud)