1

I don't know how to phrase this correctly, because Sliders are something different.

What I want to create is a multi-frame Window, with resizeable frames. Such as Qt Designer has itself (left circle), and as seen in another java app (right circle):

Resizable Windows

I'd like to know what kind of Qt Widgets to use and/or which properties to set, to get such a resizing slider between them.

Community
  • 1
  • 1
nyov
  • 1,382
  • 7
  • 23

1 Answers1

1

You have to use QSplitter:

import sys
import random
from PyQt4 import QtGui, QtCore

class MainWindow(QtGui.QMainWindow):
   def __init__(self, parent=None):
      super(MainWindow, self).__init__(parent)
      splitter = QtGui.QSplitter()
      self.setCentralWidget(splitter)
      for i in range(4):
         label = QtGui.QLabel(
            text="label {}".format(i),
            alignment=QtCore.Qt.AlignCenter
         )
         color = QtGui.QColor(*random.sample(range(255), 3))
         label.setStyleSheet("background-color:{};".format(color.name()))
         splitter.addWidget(label)

def main():
   app = QtGui.QApplication(sys.argv)
   w = MainWindow()
   w.resize(960, 480)
   w.show()
   sys.exit(app.exec_())

if __name__ == '__main__':
   main()

In Qt Designer the QSplitter component does not exist, you can only do it by code.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
  • Awesome! That made me to look for `QSplitter`, and showed me that it's also possible in Qt Designer (these days?): https://stackoverflow.com/a/28313475/9214854 – nyov Feb 27 '19 at 00:03
  • @nyov You are correct, it can be used in Qt Designer. – eyllanesc Feb 27 '19 at 00:07