Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Qt Academy Launch in California!

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

    General and Desktop
    2
    3
    547
    Loading More Posts
    • 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.
    • ?
      A Former User last edited by A Former User

      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 Reply Quote 0
      • Joel Bodenmann
        Joel Bodenmann last edited by

        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 Reply Quote 0
        • ?
          A Former User last edited by

          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 Reply Quote 0
          • First post
            Last post