• 5563阅读
  • 5回复

如何鼠标不按下相应mouseMoveEvent 【已解决】 [复制链接]

上一主题 下一主题
离线cailu2121
 
只看楼主 倒序阅读 楼主  发表于: 2010-04-07
include部分:#ifndef QTMAINTEST_H
#define QTMAINTEST_H

#include <QtGui/QMainWindow>
#include "ui_qtmaintest.h"

class qtMainTest : public QMainWindow
{
    Q_OBJECT

public:
    qtMainTest(QWidget *parent = 0, Qt::WFlags flags = 0);
    ~qtMainTest();

private:
    Ui::qtMainTestClass ui;
public slots:
    void mainTestt();
    virtual void mouseMoveEvent( QMouseEvent* event );
};

#endif // QTMAINTEST_H
cpp部分:

#include "qtmaintest.h"

qtMainTest::qtMainTest(QWidget *parent, Qt::WFlags flags)
    : QMainWindow(parent, flags)
{
    ui.setupUi(this);
    this->setMouseTracking(true);
}

qtMainTest::~qtMainTest()
{

}
void qtMainTest::mainTestt()
{

}
void qtMainTest::mouseMoveEvent( QMouseEvent* event )
{
     bool is = this->hasMouseTracking();//此处IS为真
                      int ii = 0;
}
不知道为什么看帮助说把setMouseTracking打开就好了
为什么我这里缺没用嫩 IDE :VS2008 QT 4.6.2
[ 此帖被午小夜在2010-04-08 00:38重新编辑 ]
离线yangfanxing
只看该作者 1楼 发表于: 2010-04-07
~~~你的问题很乱码。。。
PHPWind好恶心。。。不想看这种界面。。。
离线cailu2121
只看该作者 2楼 发表于: 2010-04-07
现在明白了吗
其实就是我想不按下鼠标左右键 也能响应mouseMoveEvent事件 可是按照帮助说的 setMouseTracking(true) 也无法在不按鼠标左右键的情况下响应这个事件
离线yangfanxing
只看该作者 3楼 发表于: 2010-04-07
QTest::mouseMove()
应该就是你想要的~
PHPWind好恶心。。。不想看这种界面。。。
离线午小夜

只看该作者 4楼 发表于: 2010-04-07
setMouseTracing(true);  
have a look at this function in the manual.
make sure that the widget is top-level and nobody will Intercept the event.
[ 此帖被午小夜在2010-04-08 00:05重新编辑 ]
[操作系统版本]  Windows XP;Linux Ubuntu;Linux Fedora;
[Qt SDK版本]    4.7.0
[SDK 发布日期]  2010.05
[IDE(集成开发环境)] QtCreator
个人网页:http://hi.baidu.com/午小夜
學歷:Royal Jalidon
离线cailu2121
只看该作者 5楼 发表于: 2010-04-08
引用第3楼yangfanxing于2010-04-07 23:17发表的  :
QTest::mouseMove()
应该就是你想要的~

多谢 这么晚还答复 明天尝试一下
快速回复
限100 字节
 
上一个 下一个