Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt's opaqueresize property on QSplitter meaning

Tags:

qt

qsplitter

I didn't find this on the web...

What does this opaqueResize property on QSplitter (see doc) stand for?

Thanks.

like image 345
moala Avatar asked Apr 07 '11 09:04

moala


1 Answers

I am not really sure what you are asking here. It's all in the docs.

QSplitter resizes its children dynamically by default. If you would rather have QSplitter resize the children only at the end of a resize operation, call setOpaqueResize(false)

Meaning if you set setOpaqueResize(false) on your splitter, start your application and try to pull the splitter to resize the widgets it holds it will not actually resize widgets until you release the splitter. On the other hand if it is set to true it will try to resize the widgets while you are dragging the splitter handle.

It can be useful to turn this feature off if your custom widgets take long time to draw for example since it would make resizing quite slow.

But to answer your question, property opaqueResize holds whether resizing is opaque or not, i.e. will it resize the widgets while dragging the splitter or not.


Example:

Here is a PyQt example you can try (I had example laying around in Python, but it should work the same in C++):

from PyQt4 import QtGui, QtCore

class Example(QtGui.QWidget):
    def __init__(self, *args, **kwargs):
        super(Example, self).__init__(*args, **kwargs)
        top = QtGui.QLabel('test', self)
        bottom = QtGui.QPushButton('test', self)
        splitter = QtGui.QSplitter(QtCore.Qt.Vertical)
        # Try changing from False to True
        splitter.setOpaqueResize(False)
        splitter.addWidget(top)
        splitter.addWidget(bottom)
        hbox = QtGui.QHBoxLayout(self)
        hbox.addWidget(splitter)
        self.setLayout(hbox)
        self.setGeometry(250, 200, 350, 250)

def main():
    app = QtGui.QApplication([])
    ex = Example()
    ex.show()
    app.exec_()

if __name__ == '__main__':
    main()

Hope this makes things a bit clearer.

like image 181
Davor Lucic Avatar answered Oct 30 '22 02:10

Davor Lucic