隐藏Qt光标

 

QTE程序中隐藏光标显示
 
 
来源: ChinaUnix博客  日期: 2007.09.30 16:36 (共有0条评论) 我要评论
 
呵呵,开篇帖一个以前写的。

带有触摸屏的嵌入式系统中隐藏QT应用程序界面的光标十分必要,查了一些文章给出的解决方法有两种:
1、qApp->setOverrideCursor( QCursor( Qt::BlankCursor ) );
2、QWSServer::setCursorVisible(FALSE);
第一种方式是看上去比较优雅的,但是在QTE下不好用
第二种方式是在查看了一个QT开发人员回复的Email知道的,目前QTE对于第一种的方式不支持,这是一个bug但是还不足够紧迫来修正,所以给出了替代性的方法,也就是第二种方法。
详见http://lists.trolltech.com/qt-embedded-interest/2004-01/msg00018.html
http://lists.trolltech.com/qt-embedded-interest/2004-02/msg00008.html


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/49867/showart_393


167.html 

 


sudo  gedit ./drivers/video/console/softcursor.c
int soft_cursor(struct fb_info *info, struct fb_cursor *cursor)
{
/*以下注释掉*/
/*    struct fbcon_ops *ops = info->fbcon_par;
    unsigned int scan_align = info->pixmap.scan_align - 1;
    unsigned int buf_align = info->pixmap.buf_align - 1;
    unsigned int i, size, dsize, s_pitch, d_pitch;
    struct fb_image *image;
    u8 *src, *dst;

    if (info->state != FBINFO_STATE_RUNNING)
        return 0;

    s_pitch = (cursor->image.width + 7) >> 3;
    dsize = s_pitch * cursor->image.height;

    if (dsize + sizeof(struct fb_image) != ops->cursor_size) {
        if (ops->cursor_src != NULL)
            kfree(ops->cursor_src);
        ops->cursor_size = dsize + sizeof(struct fb_image);

        ops->cursor_src = kmalloc(ops->cursor_size, GFP_ATOMIC);
        if (!ops->cursor_src) {
            ops->cursor_size = 0;
            return -ENOMEM;
        }
    }

    src = ops->cursor_src + sizeof(struct fb_image);
    image = (struct fb_image *)ops->cursor_src;
    *image = cursor->image;
    d_pitch = (s_pitch + scan_align) & ~scan_align;

    size = d_pitch * image->height + buf_align;
    size &= ~buf_align;
    dst = fb_get_buffer_offset(info, &info->pixmap, size);

    if (cursor->enable) {
        switch (cursor->rop) {
        case ROP_XOR:
            for (i = 0; i < dsize; i++)
                src = image->data ^ cursor->mask;
            break;
        case ROP_COPY:
        default:
            for (i = 0; i < dsize; i++)
                src = image->data & cursor->mask;
            break;
        }
    } else
        memcpy(src, image->data, dsize);

    fb_pad_aligned_buffer(dst, d_pitch, src, s_pitch, image->height);
    image->data = dst;
    info->fbops->fb_imageblit(info, image); 注释到此为止.*/
    return 0;
}


this->setCursor(Qt::BlankCursor);   //隐藏鼠标
this->setCursor(Qt::ArrowCursor);  //显示正常鼠标

this改为需要隐藏鼠标的部件,就可以令当鼠标移动到该部件时候,效果生效


QApplication::setOverrideCursor(Qt::BlankCursor);


这样隐藏鼠标的话。开机时候会不会有一个小方框闪现?小方框就是鼠标的背景框
我用QWSServer::setCursorVisible(false);能够隐藏鼠标,但是开机时候会闪现鼠标背景框~~

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值