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. QSplitter: how to know when a widget is added/removed form the splitter
QtWS25 Last Chance

QSplitter: how to know when a widget is added/removed form the splitter

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 632 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by A Former User
    #1

    Hello,
    Is there a signal sent on a widget's addition/removal to the splitter. I tried overriding the QObject::ChildEvent() but i noticed that the splitter count isn't updated when this event is been called(although its been called several times, there isn't a call after QSplitter::count() is updated).
    I want to do some updates on splitter on each widget's add/removal.

    Please see my second post in this thread for the work around.

    1 Reply Last reply
    0
    • Joel BodenmannJ Offline
      Joel BodenmannJ Offline
      Joel Bodenmann
      wrote on last edited by
      #2

      I have never worked with QSplitter so I don't know if this is the problem or not, but did you make sure that you call the default implementation of the QSplitter::childEvent() method in your own override? Something like this:

      void MySplitter::childEvent(QChildEvent* c) {
      	// Call the default implementation
      	QSplitter::childEvent(c)
      
      	// Do my own stuff here
      	applyMagic();
      }
      

      Industrial process automation software: https://simulton.com
      Embedded Graphics & GUI library: https://ugfx.io

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        Thanks for the reply @Joel-Bodenmann
        Yes i did call QSplitter::childEvent(event),

        but i think child event is getting called after widget reparenting & also on polish events but not after QSplitter::count() is updated.

        Good thing is that i found a work around,

        • I've reimplemented QSplitter::paintEvent() and doing "MAGIC" but i found that paintEvent is called too many times.
        • So, i'm storiing QSplitter::count() in a member variable & updating it on every paintEvent(). With this i was able to "applyMagic()" only when the splitter count() is actually changed.
          I think this isn't an ideal solution but all i need is to "applyMagic()" when the splitter is about to be shown after getting widgets added/removed. (manipulating Qt event handlers to solve our purposes..:) )
        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