Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. Custom scrollbar doesn't translate to pyqt from designer
Forum Updated to NodeBB v4.3 + New Features

Custom scrollbar doesn't translate to pyqt from designer

Scheduled Pinned Locked Moved Unsolved Language Bindings
6 Posts 2 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Faustify
    wrote on last edited by
    #1

    I have designed everything properly in the PyQT designer. In there, the scrollbar looks as it should (customised by the css). Here is the code:

            self.scrollArea = QtWidgets.QScrollArea(self.frame)
            self.scrollArea.setGeometry(QtCore.QRect(50, 200, 731, 601))
            self.scrollArea.setStyleSheet("QScrollBar:vertical {\n"
    "            border: 0px solid #999999;\n"
    "            background:white;\n"
    "            width:10px;    \n"
    "            margin: 0px 0px 0px 0px;\n"
    "        }\n"
    "        QScrollBar::handle:vertical {         \n"
    "       \n"
    "            min-height: 0px;\n"
    "              border: 0px solid red;\n"
    "            border-radius: 4px;\n"
    "            background-color: gray;\n"
    "        }\n"
    "        QScrollBar::add-line:vertical {       \n"
    "            height: 0px;\n"
    "            subcontrol-position: bottom;\n"
    "            subcontrol-origin: margin;\n"
    "        }\n"
    "        QScrollBar::sub-line:vertical {\n"
    "            height: 0 px;\n"
    "            subcontrol-position: top;\n"
    "            subcontrol-origin: margin;\n"
    "        }\n"
    "\n"
    "QScrollArea,  QAbstractScrollArea, QWidget{\n"
    "    border-radius: 60px;\n"
    "    background-color: rgb(255, 255, 255);\n"
    "}\n"
    "")
            self.scrollArea.setWidgetResizable(True)
            self.scrollArea.setObjectName("scrollArea")
    

    However, when I launch this as a python application, the scrollbar looks like the default one. I am struggling to find the reason for this issue.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      I would rather use a triple-quoted string so you can more cleanly write the style sheet.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      F 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi and welcome to devnet,

        I would rather use a triple-quoted string so you can more cleanly write the style sheet.

        F Offline
        F Offline
        Faustify
        wrote on last edited by
        #3

        @SGaist This is the auto generated code by the QT designer. However, I doubt that will be the source of the issue :3

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Then please provide a minimal script that allows to reproduce this issue.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          F 1 Reply Last reply
          0
          • SGaistS SGaist

            Then please provide a minimal script that allows to reproduce this issue.

            F Offline
            F Offline
            Faustify
            wrote on last edited by
            #5

            @SGaist Here is the entire class if it helps you :)

            from PyQt5 import QtCore, QtGui, QtWidgets
            
            
            class Info_Window(object):
                def setupUi(self, MainWindow):
                    MainWindow.setObjectName("MainWindow")
                    MainWindow.resize(800, 1024)
                    MainWindow.setMinimumSize(QtCore.QSize(800, 1024))
                    MainWindow.setMaximumSize(QtCore.QSize(800, 1024))
                    MainWindow.setTabletTracking(True)
                    MainWindow.setAutoFillBackground(False)
                    MainWindow.setStyleSheet("background-color: rgb(241, 244, 253);")
                    self.centralwidget = QtWidgets.QWidget(MainWindow)
                    self.centralwidget.setObjectName("centralwidget")
                    self.frame = QtWidgets.QFrame(self.centralwidget)
                    self.frame.setGeometry(QtCore.QRect(-10, 0, 811, 1031))
                    self.frame.setStyleSheet("background-color: rgb(137, 209, 255);")
                    self.frame.setFrameShape(QtWidgets.QFrame.StyledPanel)
                    self.frame.setFrameShadow(QtWidgets.QFrame.Raised)
                    self.frame.setObjectName("frame")
                    self.label_9 = QtWidgets.QLabel(self.frame)
                    self.label_9.setGeometry(QtCore.QRect(160, 100, 471, 51))
                    font = QtGui.QFont()
                    font.setFamily("DejaVu Sans")
                    font.setPointSize(40)
                    font.setBold(True)
                    font.setItalic(False)
                    font.setWeight(75)
                    self.label_9.setFont(font)
                    self.label_9.setStyleSheet("\n"
            "color: rgb(243, 243, 243);\n"
            "")
                    self.label_9.setTextFormat(QtCore.Qt.RichText)
                    self.label_9.setAlignment(QtCore.Qt.AlignCenter)
                    self.label_9.setObjectName("label_9")
                    self.label_10 = QtWidgets.QLabel(self.frame)
                    self.label_10.setGeometry(QtCore.QRect(40, 20, 41, 41))
                    self.label_10.setText("")
                    self.label_10.setTextFormat(QtCore.Qt.RichText)
                    self.label_10.setPixmap(QtGui.QPixmap(":/newPrefix/power.png"))
                    self.label_10.setScaledContents(True)
                    self.label_10.setObjectName("label_10")
                    self.scrollArea = QtWidgets.QScrollArea(self.frame)
                    self.scrollArea.setGeometry(QtCore.QRect(50, 200, 731, 601))
                    self.scrollArea.setStyleSheet("QScrollBar:vertical {\n"
            "            border: 0px solid #999999;\n"
            "            background:white;\n"
            "            width:10px;    \n"
            "            margin: 0px 0px 0px 0px;\n"
            "        }\n"
            "        QScrollBar::handle:vertical {         \n"
            "       \n"
            "            min-height: 0px;\n"
            "              border: 0px solid red;\n"
            "            border-radius: 4px;\n"
            "            background-color: gray;\n"
            "        }\n"
            "        QScrollBar::add-line:vertical {       \n"
            "            height: 0px;\n"
            "            subcontrol-position: bottom;\n"
            "            subcontrol-origin: margin;\n"
            "        }\n"
            "        QScrollBar::sub-line:vertical {\n"
            "            height: 0 px;\n"
            "            subcontrol-position: top;\n"
            "            subcontrol-origin: margin;\n"
            "        }\n"
            "\n"
            "QScrollArea,  QAbstractScrollArea, QWidget{\n"
            "    border-radius: 60px;\n"
            "    background-color: rgb(255, 255, 255);\n"
            "}\n"
            "")
                    self.scrollArea.setWidgetResizable(True)
                    self.scrollArea.setObjectName("scrollArea")
                    self.scrollAreaWidgetContents = QtWidgets.QWidget()
                    self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 721, 851))
                    self.scrollAreaWidgetContents.setStyleSheet("background-color: rgb(255, 255, 255);\n"
            "border-radius: 60px;")
                    self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents")
                    self.verticalLayout = QtWidgets.QVBoxLayout(self.scrollAreaWidgetContents)
                    self.verticalLayout.setObjectName("verticalLayout")
                    self.label = QtWidgets.QLabel(self.scrollAreaWidgetContents)
                    self.label.setObjectName("label")
                    self.label.setStyleSheet("padding : 2px")
                    self.verticalLayout.addWidget(self.label)
                    self.scrollArea.setWidget(self.scrollAreaWidgetContents)
                    MainWindow.setCentralWidget(self.centralwidget)
            
                    self.retranslateUi(MainWindow)
                    QtCore.QMetaObject.connectSlotsByName(MainWindow)
            
                def retranslateUi(self, MainWindow):
                    _translate = QtCore.QCoreApplication.translate
                    MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
                    self.label_9.setText(_translate("MainWindow", "INFO"))
                    self.label_10.setWhatsThis(_translate("MainWindow", "<html><head/><body><p><br/></p></body></html>"))
                    self.label.setText(_translate("MainWindow", "A\n"
            " A\n"
            "AA\n"
            " A\n"
            "AA\n"
            " A\n"
            "AA\n"
            " A\n"
            "AA\n"
            " A\n"
            "AA\n"
            " A\n"
            "AA\n"
            " A\n"
            "AA\n"
            " A\n"
            "AA\n"
            " A\n"
            "AA\n"
            " A\n"
            "AA\n"
            " A\n"
            "AA\n"
            " A\n"
            "AA\n"
            " A\n"
            "AA\n"
            " A\n"
            "AA\n"
            " A\n"
            "AA\n"
            " A\n"
            "AA\n"
            " A\n"
            "AA\n"
            " A\n"
            "AA\n"
            " A\n"
            "AA\n"
            " A\n"
            "AA\n"
            " A\n"
            "AA\n"
            " A\n"
            "AA\n"
            " A\n"
            "AA\n"
            " A\n"
            "A"))
            
            
            ui = new Info_Window()
            ui.setupUi(MainWindow)
            MainWindow.show()
            
            
            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Tested on a Mac with PyQt installed through conda. Package is pyqt-5.12.3.

              The scrollbar is changed.

              Note that your code cannot be run directly, it's missing a QMainWindow instance as well as the QApplication part.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved