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. QToolBar - itemAt(event->pos()) ?

QToolBar - itemAt(event->pos()) ?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 778 Views
  • 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.
  • D Offline
    D Offline
    Dariusz
    wrote on last edited by
    #1

    Hey!

    How can I get an item from under the mouse?

    TIA

    jsulmJ 1 Reply Last reply
    0
    • D Offline
      D Offline
      Dariusz
      wrote on last edited by
      #2
      for (auto &item:actions()) {
                      QWidget *wid = widgetForAction(item);
                      QRect r = wid->rect();
                      r.moveTo(wid->pos());
                      qDebug() << r.contains(event->pos());
                  }
      

      This seems to be working... feels a bit "odd" tho ?

      1 Reply Last reply
      0
      • D Dariusz

        Hey!

        How can I get an item from under the mouse?

        TIA

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @Dariusz Can you explain better what you mean?
        "QToolBar - itemAt(event->pos()) ?" - what does this mean? You click on QToolBar and want to know which item is under the mouse cursor? Wouldn't that be the QToolButton you clicked?

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • D Offline
          D Offline
          Dariusz
          wrote on last edited by
          #4

          Yep. I was implementing drag/drop function to drop an item at a specific place and I needed an underlying item to paint drop indicator. All done now, I used the above loop to determine what item I had beneath. However, if you have another idea about getting the item from under the mouse let me know :- )

          1 Reply Last reply
          0
          • D Offline
            D Offline
            Dariusz
            wrote on last edited by
            #5

            Ok found a better way heh.

            QWidget *widgetPTr = widgetForAction(actionAt(event->pos()));
            
            

            :- ) QtoolBar has actionAt instead of itemAt :- )

            1 Reply Last reply
            1

            • Login

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