Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3799896
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T13:48:29+00:00 2026-05-19T13:48:29+00:00

I’m diving into PyQt, and I’ve come across a little annoyance. SLOT(‘insertColumn()’) does nothing

  • 0

I’m diving into PyQt, and I’ve come across a little annoyance. SLOT(‘insertColumn()’) does nothing when attached to a button in the GUI. SLOT(‘clear()’) works perfectly, and insertColumn() works outside of the binding. insertColumn() is listed as a public slot in the Qt documentation, so I’m stuck.

Here’s the code:

class MainWindow(QMainWindow):
    def __init__(self, *args):
        QMainWindow.__init__(self, *args)

        # Table
        self.tableWidget = QTableWidget(6, columnCount, self);
        x = 0
        for x in range(0, columnCount):
            self.tableWidget.setColumnWidth(x, 30)
        for x in range(0, 6):
            self.tableWidget.setRowHeight(x, 24)

        # Window geometery and layout
        self.resize(800, 600)
        self.setWindowTitle('PyTab')
        self.setCentralWidget(self.tableWidget)

        # Menu and toolbar actions
        self.MenuExit = QAction(QIcon('exit.png'), 'Exit', self)
        self.MenuExit.setShortcut('Ctrl+Q')
        self.connect(self.MenuExit, SIGNAL('triggered()'), SLOT('close()'))

        self.MenuAddColumn = QAction(QIcon('clear.png'), 'Add Column', self)
        self.MenuAddColumn.setShortcut('Ctrl+N')

        #This line works:
        self.tableWidget.insertColumn(2)

        # I'm not sure why this line isn't working:
        self.connect(self.MenuAddColumn, SIGNAL('triggered()'), self.tableWidget, SLOT('insertColumn(2)'))

I’ve tried defining the QTableWidget as tableWidget and self.tableWidget, but that didn’t change anything.

Does anybody know what’s causing this?


Here’s the final code:

def add_column(self):
    tableWidget.insertColumn(1)
self.MenuAddColumn.triggered.connect(add_column)

It uses the new .connect() syntax as described in this SO question. Thanks again!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T13:48:30+00:00Added an answer on May 19, 2026 at 1:48 pm

    The call to .connect() only sets up the relationship for the signal and the slot. You can’t actually pass values to the slot in the .connect() call. You can create your own slot and put that in the call to .connect() and then in your own slot implementation call self.tableWidget.insertColumn(2).

    Edit:
    Just to clarify..although the slot can’t directly take values in the call to .connect(), it can receive parameters that are defined for the signal.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I am currently running into a problem where an element is coming back from
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.