Results 1 to 3 of 3

Thread: how to set the transparent of a bitmap to a cursor

  1. #1
    Join Date
    May 2010
    Location
    China
    Posts
    66
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Red face how to set the transparent of a bitmap to a cursor

    hi ,i want to creat a custorm cursor from a bmp file, i used the code as below ,anyone can help me?
    Qt Code:
    1. QBitmap pic(":/MainForm/images/CrossCursor.bmp",0);
    2. pic.createMaskFromColor(QColor(Qt::red),Qt::MaskOutColor);
    3.  
    4. QCursor curs(pic,-1,-1);
    5.  
    6.  
    7. this->setCursor(curs);
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    May 2010
    Location
    China
    Posts
    66
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to set the transparent of a bitmap to a cursor

    is there anyone can help me?

  3. #3
    Join Date
    Jun 2010
    Location
    Salatiga, Indonesia
    Posts
    160
    Thanks
    11
    Thanked 32 Times in 29 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    1

    Default Re: how to set the transparent of a bitmap to a cursor

    This is how i do it
    Qt Code:
    1. QPixmap pix(":/cur.bmp");
    2. pix.setMask(QBitmap(QPixmap(":/mask.bmp")));
    3. setCursor(QCursor(pix));
    To copy to clipboard, switch view to plain text mode 
    Attached Images Attached Images
    Last edited by saa7_go; 29th August 2010 at 06:23.

  4. The following user says thank you to saa7_go for this useful post:

    xiongxiongchuan (29th August 2010)

Similar Threads

  1. Saving Pimap to Bitmap
    By dbrmik in forum Newbie
    Replies: 3
    Last Post: 26th November 2008, 13:34
  2. Port MFC BITMAP Code to Qt?
    By pospiech in forum Qt Programming
    Replies: 3
    Last Post: 28th July 2008, 18:53
  3. Bitmap border
    By SailinShoes in forum Qt Programming
    Replies: 5
    Last Post: 14th May 2008, 18:37
  4. diplay and resize bitmap
    By tommy in forum Qt Programming
    Replies: 8
    Last Post: 14th November 2007, 17:35
  5. Bitmap buttons
    By BloodHo in forum Newbie
    Replies: 1
    Last Post: 4th November 2006, 14:17

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.