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. How to create a child widget floating
QtWS25 Last Chance

How to create a child widget floating

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 3.7k 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.
  • deleted57D Offline
    deleted57D Offline
    deleted57
    wrote on last edited by
    #1

    Hi all

    I would to create a child windget able to "ignore" any layout and that can be showed in any part of the main window (on top of other widgets) using main window coordinates. I know is possible to make such result by creating a widget without a parent but in this case the widget became like an indipendent window and use global screen coordinates. On the contrary I would my floating widget to be child of main window with the consequence if you move the main window this floating widget will be moved as well (basically like a MDI windows). Currently I didn't find a way for this problem yet, have you some suggestion about?

    Thank you

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      You can implement the mouseMoveEvent and use the maptoParent or mapToGlobal parameter.

      See the following code snippet. I have created my own label and set the parent as Widget. There is no layout. When I move the mouse, mylabel follows the mouse cursor.

      @void MyLabel::mouseMoveEvent(QMouseEvent *ev){
      qDebug() << " MY pos = "<< ev->pos();
      QPoint p1 = ev->pos();
      QPoint p = mapToParent(p1);
      this->setGeometry(p.x(),p.y(),this->width(),this->height());
      }@

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      0
      • deleted57D Offline
        deleted57D Offline
        deleted57
        wrote on last edited by
        #3

        Hi

        In my case I want the child widget to be moved with all main window like MDI window do. Many triks can be done but I would to knwo if it exist a "native" way to create such control...

        1 Reply Last reply
        0
        • dheerendraD Offline
          dheerendraD Offline
          dheerendra
          Qt Champions 2022
          wrote on last edited by
          #4

          ahhh....It is not trick. This is how it works. There is no ready made stuff. Check for dockwidgets if something fits your requirement.

          Dheerendra
          @Community Service
          Certified Qt Specialist
          http://www.pthinks.com

          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