【发布时间】:2012-05-25 07:55:47
【问题描述】:
我四处搜索,发现this forum thread,其中 OP 似乎遇到了我遇到的确切问题。问题是,我将如何继承 QLabel 并重新实现 mousepressed 事件?我猜应该是这样的:
class CustomLabel : public QLabel
{
public:
//what about the constructors?
void mousePressEvent ( QMouseEvent * ev );
}
void CustomLabel::mousePressEvent ( QMouseEvent * ev )
{
QPoint = ev->pos();
//I want to have another function get the event position.
//How would I achieve this? It's void!
//Is there perhaps some way to set up a signal and slot with the position?
}
在我成功创建了CustomLabel 类之后,我如何才能将它放在设计视图中?
【问题讨论】:
-
你找到第二个将标签放回主窗口的解决方案了吗?
标签: c++ qt user-interface location mouseevent