Qt opaqueresize property by QSplitter value

I did not find it on the Internet ...

What does this opaqueResize property opaqueResize in QSplitter ( see document )?

Thanks.

+7
source share
1 answer

I'm not quite sure what you are asking here. All this in docs .

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

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

It may be useful to disable this feature if your custom widgets take a long time to draw, for example, as this would make resizing quite slow.

But in order to answer your question, the opaqueResize property opaqueResize whether the resizing is opaque or not, i.e. whether widgets are resized when dragging the separator or not.


Example:

Here is a PyQt example that you can try (I had an example lying in Python, but it should work 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 it a little easier.

+10
source

All Articles