1# you need to import QSlider from PyQt5.QtWidgets first
2from PyQt5.QtWidgets import QSlider
3
4layout = QVBoxLayout() # or QHBoxLayout
5slider = QSlider(Qt.Horizontal) # or Qt.Vertical
6slider.setMinimum(10) # set min limit
7slider.setMaximum(30) # set max limit
8slider.setValue(20) # initiate value
9slider.setTickPosition(QSlider.TicksBelow) # set the Ticks at below the slider
10slider.setTickInterval(5) # set Tick Interval
11layout.addWidget(slider) # finally add it to your layout