×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Nov 2008
    Posts
    15

    QDrag custom pixmap icon not working in 4.6.0 tp2

    Hi!

    If setting a custom pixmap with QDrag's setPixmap(const QPixmap &pixmap) it will follow the drag only for a very short moment and then stop (with artifacts). It also starts by flashing a black background. The drag operation itself works ok. This can be easily seen by compiling the 'puzzle' drag and drop example. Hopefully this will be fixed in the final release. I tried on 4.6.0~git20091218-0maemo1.

    >> Johannes <<

  2. #2
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

  3. #3
    Registered User
    Join Date
    Nov 2008
    Posts
    15

    Re: QDrag custom pixmap icon not working in 4.6.0 tp2

    Quote Originally Posted by kleimola View Post
    If setting a custom pixmap with QDrag's setPixmap(const QPixmap &pixmap) it will follow the drag only for a very short moment and then stop (with artifacts). It also starts by flashing a black background. The drag operation itself works ok. This can be easily seen by compiling the 'puzzle' drag and drop example. Hopefully this will be fixed in the final release. I tried on 4.6.0~git20091218-0maemo1.
    Seems that the convenience functionality of movable items with QGraphicsItem::setFlag( ItemIsMovable ) works without problems though. So if the item's pixmap itself is ok as the dragging icon, then reimplementing the mousePress, mouseRelease and mouseMove in e.g. scene for more control will give similar behavior as with custom QDrag (not the MimeData functionality though I think). When using this approach you can skip all the dragEnter, dragLeave, dragMove and dropEvent functions (they seem not to be called without custom QDrag exec?). Since the default convenience functionality starts moving the item immediately (which may be unwanted with Maemo5's finger UI) you can delay it and even separate mouse press from move with this simple reference code example in a reimplemented QGraphicsScene

    Code:
    void MyScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)
    {
        if (mouseEvent->buttons() != Qt::NoButton && ourItem.isSelected()) {
            if((mouseEvent->screenPos() - mouseEvent->buttonDownScreenPos(Qt::LeftButton))
                .manhattanLength() > QApplication::startDragDistance()) {
                    QGraphicsScene::mouseMoveEvent(mouseEvent);
            }
        }
    }
    
    void MyScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
    {
        if (...) {
            // Don't dispatch mousePressEvent to the item if we don't want to move it
        }
        else
            QGraphicsScene::mousePressEvent(mouseEvent);
    }
    
    void MyScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
    {
        // Let QGraphicsItem handle mouseRelease first (otherwise our setPos() won't work)
        QGraphicsScene::mouseReleaseEvent(mouseEvent);
        if (...) {
            // If we need to cancel the drag or similar, we can reposition the item here
            ourItem->setPos(some_X_otherthanDragResult, some_Y_otherthanDragResult);
        }
    }
    Let me know if you know a better way or there's something strange here. I wonder if the default convenience functionality is faster/lighter than reimplementing everything with QDrag and the dragevents (when they will eventually work)?

    >> Johannes <<

  4. #4
    Super Contributor
    Join Date
    Mar 2009
    Posts
    1,024

    Re: QDrag custom pixmap icon not working in 4.6.0 tp2

    Hi!
    This is not an issue related to Qt itself, but it's an hildon desktop limitation.
    If you kill hildon desktop drag & drop animations work fine.

    Graphics view items are not affected by this.. problem start if you want to drag an Icon from a widget to another one.
    Puzzle Qt example shows the issue. ColorCode example available in extras-devel shows it.

  5. #5
    Registered User
    Join Date
    Nov 2010
    Posts
    1

    Re: QDrag custom pixmap icon not working in 4.6.0 tp2

    I know this is an old thread, but it was the only one google summoned when i hit this problem with drag/drop in maemo 5.

    I found a workaround for this problem from gnuton's reply about hildon-desktop being the problem.

    The solution that works for me is to set your application to be full screen.
    Dnd works flawlessly, but this of course limits the dnd possibilities between applications, but it works between widgets in your own application at least!

    Just call set fullscreen in your widget to work around this problem!
    Code:
    MyQWidget::MyQWidget(QWidget * parent)  : QWidget(parent)
    {
    setFullScreen();
    }

Similar Threads

  1. Replies: 7
    Last Post: 2007-09-05, 10:38
  2. Custom App Icon?
    By Rozik in forum Symbian
    Replies: 2
    Last Post: 2007-04-02, 10:37
  3. N80 midlet icon problem revisited... questions
    By kounapuu in forum Mobile Java General
    Replies: 1
    Last Post: 2006-10-07, 20:15
  4. Custom Icon in Incoming Bio-Message
    By ilsocio in forum Symbian
    Replies: 0
    Last Post: 2003-08-29, 13:58

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×