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. Child widget hides when mouse events are triggered?
Qt 6.11 is out! See what's new in the release blog

Child widget hides when mouse events are triggered?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 414 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.
  • C Offline
    C Offline
    Calicoder
    wrote on last edited by
    #1

    Good day, hope you're doing well. I have a parent QWidget AppMain that accepts mouse events and inside it I load another QWidget AppChildWidget that I can show with a button click. All works well except the child qwidget hides everytime I do any mouse events in the parent qwidget. Something as simple as clicking inside the parent hides the child widget. As soon as I stop the mouse events it shows again. Can this be fixed anyway? I tried setting the Qt::WindowsFlags() to always stay on top but it's not working.

    AppMain

    AppMain::AppMain(QWidget* parent) : QWidget(parent)
    {
    }
    
    AppMain::showChildWidget(bool showChildWidget)
    {
    	ui.appChildWidget->setWindowFlags(Qt::WindowStaysOnTopHint);
    	ui.appChildWidget->show();
    }
    

    AppChildWidget

    AppChildWidget::AppChildWidget(QObject* parent) : QObject(parent)
    {
    }
    

    Appreciate any help and tips. Thank you.

    dheerendraD JonBJ 2 Replies Last reply
    0
    • C Calicoder

      Good day, hope you're doing well. I have a parent QWidget AppMain that accepts mouse events and inside it I load another QWidget AppChildWidget that I can show with a button click. All works well except the child qwidget hides everytime I do any mouse events in the parent qwidget. Something as simple as clicking inside the parent hides the child widget. As soon as I stop the mouse events it shows again. Can this be fixed anyway? I tried setting the Qt::WindowsFlags() to always stay on top but it's not working.

      AppMain

      AppMain::AppMain(QWidget* parent) : QWidget(parent)
      {
      }
      
      AppMain::showChildWidget(bool showChildWidget)
      {
      	ui.appChildWidget->setWindowFlags(Qt::WindowStaysOnTopHint);
      	ui.appChildWidget->show();
      }
      

      AppChildWidget

      AppChildWidget::AppChildWidget(QObject* parent) : QObject(parent)
      {
      }
      

      Appreciate any help and tips. Thank you.

      dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Moderators Qt Champions 2024 Qt Champions 2022 Qt Champions 2017
      wrote on last edited by
      #2

      @Calicoder
      hide means is it behind or not visible ? How the ui is initialized ? What is the code inside the mousepressevent in Appmain. Workable code snippet will help help you.

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

      1 Reply Last reply
      0
      • C Calicoder

        Good day, hope you're doing well. I have a parent QWidget AppMain that accepts mouse events and inside it I load another QWidget AppChildWidget that I can show with a button click. All works well except the child qwidget hides everytime I do any mouse events in the parent qwidget. Something as simple as clicking inside the parent hides the child widget. As soon as I stop the mouse events it shows again. Can this be fixed anyway? I tried setting the Qt::WindowsFlags() to always stay on top but it's not working.

        AppMain

        AppMain::AppMain(QWidget* parent) : QWidget(parent)
        {
        }
        
        AppMain::showChildWidget(bool showChildWidget)
        {
        	ui.appChildWidget->setWindowFlags(Qt::WindowStaysOnTopHint);
        	ui.appChildWidget->show();
        }
        

        AppChildWidget

        AppChildWidget::AppChildWidget(QObject* parent) : QObject(parent)
        {
        }
        

        Appreciate any help and tips. Thank you.

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #3

        @Calicoder
        When you create the AppChildWidget from AppMain do you indeed pass it this for its parent? Otherwise please answer @dheerendra's questions.

        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