Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Corner Widget Button is cut off?
Forum Updated to NodeBB v4.3 + New Features

Corner Widget Button is cut off?

Scheduled Pinned Locked Moved Unsolved Qt for Python
9 Posts 2 Posters 673 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
    fvez_demtroys
    wrote on last edited by fvez_demtroys
    #1

    Hi,

    I am trying to add a button as a corner widget on a QTabWidget.
    I am able to add the button just fine but for some reason it isn't showing in its entirety.
    Screenshot

    Any idea why it is cut off?
    As you can see in the image, the corner combo box isn't being cut off but the button is.
    Here is the code used to display the corner button and corner combo box :

    self.comboBox_cornerModule = QComboBox(self.centralWidget)
    self.comboBox_cornerModule.setObjectName(u"comboBox_cornerModule")
    self.comboBox_cornerModule.addItems(["Test", "Test"])
    self.tabWidget.setCornerWidget(self.comboBox_cornerModule, Qt.Corner.TopLeftCorner)
    self.comboBox_cornerModule.currentTextChanged.connect(self.toggleModule)
    
    self.pushButton_testSoftware2 = QPushButton(self.centralWidget)
    self.pushButton_testSoftware2.setObjectName(u"pushButton_testSoftware2")
    self.pushButton_testSoftware2.setDefault(True)
    self.pushButton_testSoftware2.setText('Test Software')
    self.tabWidget.setCornerWidget(self.pushButton_testSoftware2, Qt.Corner.TopRightCorner)
    

    Thanks!

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

      Hi,

      Which version of PyQt/PySide are you using ?
      On which OS ?
      Do you have a style sheet applied ?

      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
      • F Offline
        F Offline
        fvez_demtroys
        wrote on last edited by
        #3

        Hi SGaist,

        This is with PyQt5 5.15.4.
        macOS Catalina 10.15.7

        No this is all without any style sheets.
        We want the most native feel possible.

        Thanks!

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

          Can you provide a minimal script that allows to recreate that behaviour ?

          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
          • F Offline
            F Offline
            fvez_demtroys
            wrote on last edited by
            #5

            Hi SGaist,

            I just wrote a script that would allow to recreate the behaviour as requested.
            However, I seem to be unable to share it here. How could I send this over?

            When dragging the file to the reply, I get
            "
            Error
            You do not have enough privileges for this action.
            "

            Thanks

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

              Since the script is minimal, you can put its content directly in a post. Please use the </> button to format it properly.

              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
              • F Offline
                F Offline
                fvez_demtroys
                wrote on last edited by
                #7

                Hi SGaist,

                Here is the script.

                import sys
                
                
                from PyQt5.QtCore import *
                from PyQt5.QtGui import *
                from PyQt5.QtWidgets import *
                from UI import Ui_mainWindow
                
                
                class App(QMainWindow):
                	def __init__(self):
                		super(App, self).__init__()
                		self.initUI()
                		self.initWindow()
                
                	def initWindow(self):
                		self.title = 'title'
                		self.left = 0
                		self.top = 0
                		# Values if not fullscreen
                		self.width = 800
                		self.height = 600
                		self.setWindowTitle(self.title)
                		self.setGeometry(self.left, self.top, self.width, self.height)
                		self.showMaximized()
                
                	def initUI(self):
                		self.mainPage = Ui_mainWindow()
                		self.mainPage.setupUi(self)
                
                
                class Ui_mainWindow(QWindow):
                	def setupUi(self, mainWindow):
                		if not mainWindow.objectName():
                			mainWindow.setObjectName(u"mainWindow")
                		self.initCentral(mainWindow)
                		self.initTabWidget()
                
                		mainWindow.setCentralWidget(self.centralWidget)
                
                	def initCentral(self, mainWindow):
                		self.centralWidget = QWidget(mainWindow)
                		self.centralWidget.setObjectName(u"centralWidget")
                		self.baseGridLayout = QGridLayout(self.centralWidget)
                		self.baseGridLayout.setObjectName(u"baseGridLayout")
                
                	def initTabWidget(self):
                		self.tabWidget = QTabWidget(self.centralWidget)
                		self.tabWidget.setObjectName(u"tabWidget")
                		self.tabWidget.setAutoFillBackground(False)
                		self.tabWidget.setTabPosition(QTabWidget.North)
                		self.tabWidget.setTabShape(QTabWidget.Rounded)
                		self.tabWidget.setMovable(False)
                		self.initCornerRfModuleWidget()
                		self.initTab1()
                		self.initTab2()
                		self.baseGridLayout.addWidget(self.tabWidget, 0, 0, 6, 2)
                		self.tabWidget.setCurrentIndex(0)
                
                	def initCornerRfModuleWidget(self):
                		self.comboBox_cornerModule = QComboBox(self.centralWidget)
                		self.comboBox_cornerModule.setObjectName(u"comboBox_cornerModule")
                		self.comboBox_cornerModule.addItems(["Test1", "Test2"])
                		self.tabWidget.setCornerWidget(self.comboBox_cornerModule, Qt.Corner.TopLeftCorner)
                
                		self.pushButton_cornerModule = QPushButton(self.centralWidget)
                		self.pushButton_cornerModule.setObjectName(u"pushButton_cornerModule")
                		self.pushButton_cornerModule.setDefault(True)
                		self.pushButton_cornerModule.setText('Test Button')
                		self.tabWidget.setCornerWidget(self.pushButton_cornerModule, Qt.Corner.TopRightCorner)
                
                	def initTab1(self):
                		self.tab_1 = QWidget()
                		self.tab_1.setObjectName(u"tab_1")
                
                		self.gridLayout_tab_1 = QGridLayout(self.tab_1)
                
                		self.gridLayout_tab_1.setObjectName(u"gridLayout_tab_1")
                		self.gridLayout_tab_1.setContentsMargins(0, -1, 0, 0)
                
                		self.pushButton_1 = QPushButton(self.tab_1)
                		self.pushButton_1.setObjectName(u"pushButton_1")
                		self.pushButton_1.setDefault(True)
                
                		self.gridLayout_tab_1.addWidget(self.pushButton_1, 2, 6, 1, 1)
                
                		self.tabWidget.addTab(self.tab_1, "Single Device")
                
                	def initTab2(self):
                		self.tab_2 = QWidget()
                		self.tab_2.setObjectName(u"tab_2")
                		self.gridLayout_tab_2 = QGridLayout(self.tab_2)
                		self.gridLayout_tab_2.setObjectName(u"gridLayout_tab_2")
                		self.gridLayout_tab_2.setContentsMargins(0, -1, 0, 0)
                		self.groupBox_2 = QGroupBox(self.tab_2)
                		self.groupBox_2.setObjectName(u"groupBox_2")
                		self.groupBox_2.setFlat(True)
                		self.gridLayout_groupBox_2 = QGridLayout(self.groupBox_2)
                		self.gridLayout_groupBox_2.setObjectName(u"gridLayout_groupBox_2")
                
                		# Program button
                		self.pushButton_2 = QPushButton(self.groupBox_2)
                		self.pushButton_2.setObjectName(u"pushButton_2")
                		self.pushButton_2.setDefault(True)
                		self.pushButton_2.setEnabled(False)
                		self.pushButton_3 = QPushButton(self.groupBox_2)
                		self.pushButton_3.setObjectName(u"pushButton_3")
                		self.pushButton_3.setDefault(True)
                		self.pushButton_3.setEnabled(False)
                
                		self.gridLayout_groupBox_2.addWidget(self.pushButton_2, 2, 1, 1, 1)
                		self.gridLayout_groupBox_2.addWidget(self.pushButton_3, 2, 2, 1, 2)
                
                		self.gridLayout_tab_2.addWidget(self.groupBox_2, 0, 0, 2, 1)
                		self.tabWidget.addTab(self.tab_2, "Installation")
                
                
                if __name__ == "__main__":
                	app = QApplication(sys.argv)
                	ex = App()
                	# apply_stylesheet(app, theme='dark_teal.xml')
                	sys.exit(app.exec_())
                

                Hope this helps find the issue.

                Thanks!

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

                  The geometry of the corner widget will depend on the size hint of the widget and style as per the method documentation. There's likely something to search there.

                  Depending on what you want you can use a style sheet to influence the size of the corner widget.

                  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
                  • F Offline
                    F Offline
                    fvez_demtroys
                    wrote on last edited by
                    #9

                    Hi SGaist,

                    Thanks for the suggestion, I'll have a look at the size hint.

                    As for the style sheet, I tried that but you instantly lose the native look of the UI, which we would like to avoid.

                    Thanks!

                    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