PDA

View Full Version : QDrag setPixmap failed with "XBM" format



alfa_wu
30th April 2007, 08:36
Hi all,
I got trouble when QDrag setPixmap with "XBM" format.(X11 env.)
You can reproduce it by modify exmaple ~qt4.x.src/examples/draganddrop/draggableicons/dragwidget.cpp
Replace Line #110 ( drag->setPixmap(pixmap); ) with


{
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};

QBitmap pixmap = QBitmap::fromData(
QSize(20, 20), drag_bits, QImage::Format_Mono);
pixmap.setMask(QPixmap::grabWidget(this).createHeu risticMask(true));
drag->setPixmap((QPixmap)pixmap);

}

When we start dragging,
we can find the icon is not xbm format, it become color not mono.:confused:
And draggable icon contain background color :confused:

Does anyone can help me?
I need mono draggable icon.(XBM format)

marcel
1st May 2007, 19:20
QPixmap is always ARGB.

Maybe if you explain what you're trying to achieve, I can help you with an example.

Regards

alfa_wu
2nd May 2007, 03:32
Hi Marcel,

I try to start drag with an mono color icon/cursor. (XBM format, or QBitmap)
May I achieve it?

Regards