Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. change the position of buttons in a QHBoxLayout
Forum Updated to NodeBB v4.3 + New Features

change the position of buttons in a QHBoxLayout

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 227 Views
  • 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.
  • S Offline
    S Offline
    sof4Rou
    wrote on last edited by
    #1

    Capture.PNG
    I want to change th position of "+" , "Verify" and "Correct" buttons to the top ( next to the headers of the table) . Here is my code :

    def SpecForm(self):
            spec = QDialog(self)
            spec.setWindowTitle('Spécifications du Client')
            spec.resize(800, 600)
            main_layout = QHBoxLayout(spec)
    
            self.table = QTableWidget(0, 3) 
            self.table.verticalHeader().setVisible(False)
            self.table.setHorizontalHeaderLabels(['Object', 'User/Group', 'r    w    x'])
            self.table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
    
            main_layout.addWidget(self.table)
    
            add_row_button = QPushButton('+')
            add_row_button.setStyleSheet("""
            QPushButton {
                border-radius: 15px;  
                background-color: blue;
                color: white;
                font-size: 16px;
                padding: 0px;
            }
            QPushButton:hover {
                background-color: navy;
            }
            QPushButton:pressed {
                background-color: darkblue;
            }
        """)
            add_row_button.clicked.connect(self.add_table_row)
            main_layout.addWidget(add_row_button)
    
            submit_button = QPushButton('Verify')
            submit_button.clicked.connect(self.validate_spec)
            main_layout.addWidget(submit_button)
    
            corr_button = QPushButton('Correct')
            main_layout.addWidget(corr_button)
    
            spec.setLayout(main_layout)
            spec.exec_()
    

    Can anyone help me ?

    1 Reply Last reply
    0
    • B Offline
      B Offline
      Bonnie
      wrote on last edited by
      #2
      main_layout.addWidget(add_row_button, 0, Qt.AlignTop)
      
      S 1 Reply Last reply
      2
      • B Bonnie
        main_layout.addWidget(add_row_button, 0, Qt.AlignTop)
        
        S Offline
        S Offline
        sof4Rou
        wrote on last edited by
        #3

        @Bonnie Thank you very much

        1 Reply Last reply
        0
        • S sof4Rou has marked this topic as solved on

        • Login

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