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. Dock widget not visible
Forum Update on Monday, May 27th 2025

Dock widget not visible

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 1 Posters 158 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.
  • PerdrixP Offline
    PerdrixP Offline
    Perdrix
    wrote on last edited by Perdrix
    #1

    I have a dock widget that's owned by a QDialog that may not be visible under all circumstances when the application is closed and the window state is saved.

    When I restart I want to show this dialog and the dock widget.

    So in onInitialise() that I call from here:

    void DeepSkyStacker::showEvent(QShowEvent* event)
    {
    	// Invoke base class showEvent()
    	Inherited::showEvent(event);
    	if (!event->spontaneous())
    	{
    		if (!initialised)
    		{
    			initialised = true;
    			onInitialise();
    		}
    	}
    }
    

    I wrote:

    	stackingDlg->setVisible(true);
    	setTab(IDD_REGISTERING);
    	update();
    

    which in turn called code that did this:

    	stackedWidget->setCurrentIndex(0);
    	stackingDlg->showImageList();
    	stackingDlg->update();
    

    where the call to stackingDlg->showImageList() calls setVisible(true) for the dock widget.

    Problem is that it didn't work :(

    In the end, in a fit of desperation, I changed the code in onInitialise() to read:

    	QTimer::singleShot(20,
    		[this]()
    		{
    			this->stackingDlg->setVisible(true);
    			this->setTab(IDD_REGISTERING);
    			this->update();
    		});
    

    and lo it all works as I expect.

    Please can someone explain why I needed to put that code into a single shot?

    PerdrixP 1 Reply Last reply
    0
    • PerdrixP Perdrix

      I have a dock widget that's owned by a QDialog that may not be visible under all circumstances when the application is closed and the window state is saved.

      When I restart I want to show this dialog and the dock widget.

      So in onInitialise() that I call from here:

      void DeepSkyStacker::showEvent(QShowEvent* event)
      {
      	// Invoke base class showEvent()
      	Inherited::showEvent(event);
      	if (!event->spontaneous())
      	{
      		if (!initialised)
      		{
      			initialised = true;
      			onInitialise();
      		}
      	}
      }
      

      I wrote:

      	stackingDlg->setVisible(true);
      	setTab(IDD_REGISTERING);
      	update();
      

      which in turn called code that did this:

      	stackedWidget->setCurrentIndex(0);
      	stackingDlg->showImageList();
      	stackingDlg->update();
      

      where the call to stackingDlg->showImageList() calls setVisible(true) for the dock widget.

      Problem is that it didn't work :(

      In the end, in a fit of desperation, I changed the code in onInitialise() to read:

      	QTimer::singleShot(20,
      		[this]()
      		{
      			this->stackingDlg->setVisible(true);
      			this->setTab(IDD_REGISTERING);
      			this->update();
      		});
      

      and lo it all works as I expect.

      Please can someone explain why I needed to put that code into a single shot?

      PerdrixP Offline
      PerdrixP Offline
      Perdrix
      wrote on last edited by
      #2

      @Perdrix I got round that ugly hack by making the dock widget in question visible as the application was closing (in the closeEvent handler).

      Still don't understand why that "One Shot" was needed though.

      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