void StyledButton::mouseMoveEvent(QMouseEvent* e) { QButton::mouseMoveEvent( e ); #ifndef QT_NO_DRAGANDDROP if ( !mousePressed ) return; if ( ( pressPos - e->pos() ).manhattanLength() > QApplication::startDragDistance() ) { if ( edit == ColorEditor ) { QColorDrag *drg = new QColorDrag( col, this ); QPixmap pix( 25, 25 ); pix.fill( col ); QPainter p( &pix ); p.drawRect( 0, 0, pix.width(), pix.height() ); p.end(); drg->setPixmap( pix ); mousePressed = FALSE; drg->dragCopy(); } else if ( edit == PixmapEditor && pix && !pix->isNull() ) { QImage img = pix->convertToImage(); QImageDrag *drg = new QImageDrag( img, this ); if(spix) drg->setPixmap( *spix ); mousePressed = FALSE; drg->dragCopy(); } } #endif }
void ImageButton::startDrag() { if(!mPicture.data().isNull()) { QImageDrag *drag = new QImageDrag(mPicture.data(), this); drag->dragCopy(); } }