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. "Sticky option" for widget based window
Forum Updated to NodeBB v4.3 + New Features

"Sticky option" for widget based window

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

    I try to implement a sticky = always-on-top option for a "homebrew" window, based on a QWidget created without parent. The widow is created and controlled from a normal QMainWindow-derived application.

    window=new QWidget(nullptr, Qt::CustomizeWindowHint | Qt::WindowTitleHint);
    

    The window looks and works as expected. It contains a sticky-checkbox, which toggles the WindowStaysOnTopHint:

    void DlgSceneView::stayOnTopSl(bool enabled)
    {
    	window->setWindowFlag(Qt::WindowStaysOnTopHint, enabled);
    }
    

    Strange behavior: The widow "vanishes" (hides?) as soon as I toggle this flag, BUT when I show the window again (through a user action from the main application), it works. I can turn the sticky behabior on and off.
    So I tried to include the show action directly in the event slot:

    void DlgSceneView::stayOnTopSl(bool enabled)
    {
    	window->setWindowFlag(Qt::WindowStaysOnTopHint, enabled);
    	window->show();
    }
    

    This does show the window as expected but suddenly the sticky behavior is permanently lost, it always follows normal stacking order.
    Qt 5.15.2 on Ubuntu 20.04.5 LTS with "standard" GNOME.
    Does anyone have an idea why

    • The widow hides at all
    • The show command preservers the sticky behavior if show is call from the message queue of the QMainWindow but not if called from within the windows own queue?

    Many thanks!

    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