void KSnapshot::slotDragSnapshot() { QDragObject *drobj = new QImageDrag(snapshot.convertToImage(), this); Q_CHECK_PTR(drobj); drobj->setPixmap(mainWidget->preview()); drobj->dragCopy(); }
void mousePressEvent(QMouseEvent *e) { if(e->button() == LeftButton) { if(labeltype == Des) return; QDragObject *drobj = 0; if(pixmap()) { // 如果有圖片 // 產生QDragObject drobj = new QImageDrag(pixmap()->convertToImage(), this); QPixmap pm; // 產生縮圖 pm.convertFromImage( pixmap()->convertToImage().smoothScale(25, 25)); // 拖曳時的顯示圖形與游標位移 drobj->setPixmap(pm, QPoint(-14, -20)); } else if(text()) { // 如果有文字 drobj = new QTextDrag(text(), this); drobj->setPixmap(QPixmap("text.gif"), QPoint(-25, -15)); } // ?#125;始拖放動作 if(drobj) drobj->dragCopy(); } }
void TextShow::startDrag() { QDragObject *drag = new QTextDrag(selectedText(), viewport()); if ( isReadOnly() ) { drag->dragCopy(); } else { if ( drag->drag() && QDragObject::target() != this && QDragObject::target() != viewport() ) removeSelectedText(); } }
void DropSite::mousePressEvent( QMouseEvent * /*e*/ ) { QDragObject *d; if ( pixmap() ) { d = new QImageDrag( pixmap()->convertToImage(), this ); QPixmap pm; pm.convertFromImage(pixmap()->convertToImage().smoothScale( pixmap()->width()/3,pixmap()->height()/3)); d->setPixmap(pm,QPoint(-5,-7)); } else { d = new QTextDrag( text(), this ); } d->dragCopy(); }
/*! mouseMoveEvent - mouse move on the list box */ void DDListBox::mouseMoveEvent( QMouseEvent * ) { if (count() == max_items && max_items != 0 && flag) { for (unsigned int i = 0; i < count(); i++) changeItem( QPixmap( green_icon ) , text(i) , i); flag = false; } if ( dragging && item(currentItem())->isSelectable() ) { QDragObject *d = new QTextDrag( currentText() , this ); d->dragCopy(); // do NOT delete d. dragging = FALSE; unsigned int current = currentItem(); if (count() == max_items && max_items != 0) { char s[100]; strcpy(s, currentText()); char * traits; traits = strtok(s," "); traits = strtok(NULL, " "); traits = strtok(NULL, " "); traits = strtok(NULL, " "); for (unsigned int i = 0; i < max_items; i++) { char s_i[100]; strcpy(s_i, text(i)); char * traits_i; traits_i = strtok(s_i," "); traits_i = strtok(NULL, " "); traits_i = strtok(NULL, " "); traits_i = strtok(NULL, " "); bool b = (strcmp(traits,traits_i) == 0); if (!b && i != current ) { changeItem( QPixmap( white_icon ) , text(i) , i); item(i)->setSelectable( b ); } } } removeItem ( current ); } }
void Test::initiateDrag( QWidget *w ) { QDragObject *d = new QTextDrag( mWidget->label( mWidget->indexOf( w ) ), this ); d->dragCopy(); // do NOT delete d. }
//! [0] void MyQt3Widget::customStartDragFunction() { QDragObject *d = new QTextDrag( myHighlightedText(), this ); d->dragCopy(); // do NOT delete d. }