PDA

View Full Version : Editing resizeEvent of a form-set object



Momergil
17th January 2013, 00:28
Hello!

I'm having a situation where I put some QwtPlot inside a QSplitter in the .ui and that needs to be resize() each time the size of the QSplitter changes. For that, I guess, I need to extend the QSplitter resizeEvent() adding there the code to resize the QwtPlot each time its fired.

The problem is that I have no idea of how to do that, since resizeEvent() is not a signal or slot of QSplitter. I know how to do the edit the resizeEvent() when I'm working in the .h and .cpp of a given class:



//.h

//....
protected:
void resizeEvent(QResizeEvent *event);

//...

//.cpp

//...

void MainWindow::resizeEvent(QResizeEvent *event)
{
//code that should be executed when MainWindonw fires a resizeEvent();
}



, but not "externaly". So how should I do this? Remember though: I want to "edit", so-to-speak, the resizeEvent() of a specific QSplitter, not making this valid to the entire class.


Thanks,

Momergil

wysota
17th January 2013, 03:22
You can always install an event filter on a specified instance of QSplitter to capture events of that instance only. However I have no idea what you need it for.

Momergil
17th January 2013, 11:25
Well, how exactly should I do that? (could you provide a code example?)

Well, once again, I need because I need to capture the resizeEvent() of a particular QSplitter in my form.

anda_skoa
17th January 2013, 11:27
Isn't that what a Splitter is doing as part of its normal behavior?

I just tried with two QTextEdit in a splitter in QtDesigner and even in preview mode it resizes the two edit widgets whenever the slider handle is moved.

Cheers,
_

wysota
17th January 2013, 11:36
If you remember to put widgets in a layout...

@Momergil:

Well, how exactly should I do that? (could you provide a code example?)
See QObject::installEventFilter()

Momergil
17th January 2013, 13:41
Isn't that what a Splitter is doing as part of its normal behavior?

I just tried with two QTextEdit in a splitter in QtDesigner and even in preview mode it resizes the two edit widgets whenever the slider handle is moved.

Cheers,
_

Not exactly. If you move the slider handler of the QSplitter, the size of its child widgets do change, but no the size of the QSplitter itself, and the changes of QSplitter's size that I want to capture, not of the widgets that it possess.


Wysota,

thanks, I'll give a look at that and see what I can do.

wysota
17th January 2013, 13:52
If you move the slider handler of the QSplitter, the size of its child widgets do change, but no the size of the QSplitter itself
That's how a splitter is to behave. Manipulating inside of a window shouldn't influence outside of the window. If you wish to resize the window, do it the way it is supposed to be done -- by dragging the outer window frame (or whatever mechanism exists in the window manager you are using).

Momergil
17th January 2013, 16:10
That's how a splitter is to behave. Manipulating inside of a window shouldn't influence outside of the window. If you wish to resize the window, do it the way it is supposed to be done -- by dragging the outer window frame (or whatever mechanism exists in the window manager you are using).

Well, I know that it is supposed to be so ^^ I was only telling anda_skoa the difference between what we get with moving the slider hander of QSplitter and what I actually want to grab ;)

--
Now I was thinking: if the QSplitter is inside a QGridLayout or something that when I resize the MainWindow it automatically resizes the QSpliter thanks to the layout, than actually I don't need the resizeEvent of the QSplitter, since it will happen always when the MainWindow's resizeEvent happens. :S