Results 1 to 9 of 9

Thread: Does QDrag support QBitmap?

  1. #1
    Join Date
    Feb 2007
    Posts
    14
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Does QDrag support QBitmap?

    I wanted to drawing a mono color cursor when mouse start to drag.
    But it seems that only support QPixmap format(ARGB color, not mono color).

    Do we have method to draw mono color cursor when we start dragging ?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Does QDrag support QBitmap?

    Can we see the code? QBitmap inherits QPixmap so everything that's possible using QPixmap should be doable using QBitmap.

  3. #3
    Join Date
    Feb 2007
    Posts
    14
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Does QDrag support QBitmap?

    You can reproduce it by modify exmaple ~qt4.x.src/examples/draganddrop/draggableicons/dragwidget.cpp
    Replace Line #110 ( drag->setPixmap(pixmap); ) with

    Qt Code:
    1. Qt Code:
    2. static unsigned char drag_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x41, 0x00, 0x00, 0x41, 0x00, 0xff, 0xc1, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xf0, 0x0f, 0x40, 0x10, 0x00, 0x40, 0x10, 0x00, 0xc0, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
    3. QBitmap pixmap = QBitmap::fromData( QSize(20, 20), drag_bits, QImage::Format_Mono);
    4. pixmap.setMask(QPixmap::grabWidget(this).createHeuristicMask(true));
    5. drag->setPixmap((QPixmap)pixmap);
    To copy to clipboard, switch view to plain text mode 
    The cusor will be color, not mono

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Does QDrag support QBitmap?

    Works quite fine for me. I just replaced the construction and serialisation of the pixmap from the example with your pixmap.

  5. #5
    Join Date
    Feb 2007
    Posts
    14
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Does QDrag support QBitmap?

    It did not work in my enviornment.
    When I pressed some widget and try to move, you can find that cursor's background is wrong.
    That is, the cursor must be mono, not color.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Does QDrag support QBitmap?

    What exactly did you do? Did you replace all occurences of the color pixmap in code with the bitmap?

  7. #7
    Join Date
    Feb 2007
    Posts
    14
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Does QDrag support QBitmap?

    I only replaced Line #110 ( drag->setPixmap(pixmap); ) with my code
    Qt Code:
    1. {
    2. static unsigned char drag_bits[] = { ...};
    3. QBitmap pixmap = QBitmap::fromData( QSize(20, 20), drag_bits, QImage::Format_Mono);
    4. pixmap.setMask(QPixmap::grabWidget(this).createHeuristicMask(true));
    5. drag->setPixmap((QPixmap)pixmap);
    6. }
    To copy to clipboard, switch view to plain text mode 

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Does QDrag support QBitmap?

    As I said, you have to replace the construction and serialisation code of the pixmap. Otherwise your pixmap won't be used at all (the code I mentioned is around line #100 or earlier).

  9. #9
    Join Date
    Feb 2007
    Posts
    14
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Does QDrag support QBitmap?

    I am sorry that I can not deliver my question clearly.
    I attached drag.jpg file, and I wanted the cursor in the picture is mono-color.
    I do not wanted to change all content of pixmap.

    I only wanted to show mono-color mouse when dragging.
    That is, I wanted to set mono-color in function "drag->setPixmap()".

    Thanks your reply.
    Attached Images Attached Images

Similar Threads

  1. object-relational mapping support?
    By brcain in forum Qt Programming
    Replies: 18
    Last Post: 28th January 2016, 11:42
  2. Qt static library with jpeg support
    By vishal.chauhan in forum Installation and Deployment
    Replies: 2
    Last Post: 11th May 2007, 06:53
  3. Compile QT4.2.2 with MySQL on Mac OS
    By asd in forum Installation and Deployment
    Replies: 7
    Last Post: 12th February 2007, 14:50
  4. Qt and jpg support in Linux ?
    By probine in forum Qt Programming
    Replies: 2
    Last Post: 22nd January 2007, 23:46
  5. Strange Problem with JPEG Support on win XP
    By caligula in forum Installation and Deployment
    Replies: 3
    Last Post: 18th September 2006, 10:36

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.