Question about the MouseMoveEvent of qtdemo's TextButton



  • I would like to use MouseMoveEvent event of Textbutton in qtdemo, so that I can drag the item to the specified location.
    I add the flag "QGraphicsItem::ItemIsMovable" to item in menumanager.cpp
    @
    void MenuManager::createMenu(const QDomElement &category, BUTTON_TYPE type)
    {
    .........

            // create normal menu button
            QString label = currentNode.toElement().attribute("name");
            item = new TextButton(label, TextButton::LEFT, type, this->window->scene, this->window->mainSceneRoot);
            currentNode = currentNode.nextSibling();
    
            item->setFlags(QGraphicsItem::ItemIsMovable);
    

    .........
    }
    @
    First, Drag a item to specified location . When I click the leftbutton and start to drag the item,it will jump to (0 ,0) before the mouse moving.

    For example:
    I drag dowm a item from the location of (59, 233) to the specified location of (59, 236);
    drag item pos output:
    QPointF(59, 233)
    QPointF(0, 1)
    QPointF(0, 2)
    QPointF(0, 3)

    As you can see, the moving graber jump from (59, 233) to (0, 1).

    So I don't know what cause this result.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.