ArmanHunanyan
ArmanHunanyan

Reputation: 1015

How to listen widget's resize event from outside class

I am trying to place child widget (Which contains several QToolButtons) inside QLineEdit. I am handling QLineEdit's resizeEvent and always moving child widget to right hand side of editing area. This is working if child widget have fixed size. But when new ToolButton is added in child widget I need to listen child widgets resize event to move it in correct position. I have tried to use eventFilter but it didn't work.

ToolButtons on child widget are placed using QHBoxLayout.

Upvotes: 0

Views: 380

Answers (1)

Trenton Schulz
Trenton Schulz

Reputation: 778

Sounds to me like you are more or less doing your own layout. You may as well use Qt's infrastructure to make it easier for you.

The trick is to handle the children's (or layout's) LayoutRequest event. More information is in Qt's Layout documentation.

http://qt-project.org/doc/qt-4.8/layout.html#manual-layout

Upvotes: 1

Related Questions