Typo Qt::LeftButton? Following works fine for me:
#include <QtGui>
{
Q_OBJECT
public:
{}
protected:
{
if (event->button()==Qt::LeftButton)
{
qWarning() << Q_FUNC_INFO;
}
}
};
int main(int argc, char *argv[])
{
MyLabel l;
l.setText("foo bar");
l.show();
return app.exec();
}
#include "main.moc"
#include <QtGui>
class MyLabel : public QLabel
{
Q_OBJECT
public:
MyLabel(QWidget *parent = 0) : QLabel(parent)
{}
protected:
virtual void mousePressEvent(QMouseEvent *event)
{
if (event->button()==Qt::LeftButton)
{
qWarning() << Q_FUNC_INFO;
}
}
};
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
MyLabel l;
l.setText("foo bar");
l.show();
return app.exec();
}
#include "main.moc"
To copy to clipboard, switch view to plain text mode
Bookmarks