Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Question about the MouseMoveEvent of qtdemo's TextButton
Qt 6.11 is out! See what's new in the release blog

Question about the MouseMoveEvent of qtdemo's TextButton

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    yzdying2
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved