Related Posts

28 Comments

  1. can somebody please explain to me why is 'btn.clicked.connect(self.close_application)' instead of 'btn.clicked.connect(self.close_application())' ? I thought we needed the () to call a method

  2. I don't really understand how calling the run() method is able to work. Inside the run() method, I see that an instance of Window() is made and called "GUI", but I don't see "GUI" being called…how come the window still pops up when the program is run?

  3. hi, thank you for this great tutorials! qt its awesome! i was wondring how is possible to use the connect function with a parametrized function, if my mainwindow instance name is window, then something like:

    btn.clicked.connect(window.change_size(parameter1,parameter2)), calling this in the main and no in the class?
    hope u answer
    thanks in advice

  4. Hi sentdex I m really learning lot from your tuts, they are so helpful.

    There one problem which I am facing is, I am not able to create additional button in same script can you explain that as well ?? how we create multiple buttons ??

  5. Somehow when i tried using the setWindowTitle(stirng) within the close_application() method, it gave me an error message saying:
    btn.clicked.connect(self.close_application())
    TypeError: connect() slot argument should be a callable or a signal, not 'NoneType'
    How come it worked in your case and it didn't for me?
    Thanks for the amazing tutorials by the way.

  6. This question has been commented already, but none of them have been answered:
    How do you trigger a function when a button is pressed, *with PyQt4.5*?

    (Since the QPushButton.clicked.connect([function]) has been deprecated)
    That's like, a really essential thing..

    Figured, it's this, for the video:
    QtCore.QObject.connect(btn, QtCore.SIGNAL('clicked()'), self.close_application)
    replacing
    btn.clicked.connect(self.close_application)

  7. "Now, I understand, you're probably like 'whoa, but we already had something that could quit, this is stupid!'"

    I was actually thinking "Wow, if you could have just passed 'sys.exit()' in the first place, why did you pass 'QtCore.QCoreApplication.instance().quit'?"

  8. It's a pity you did not elaborate on binding button events to functions with parameters. To anyone interested, add 'lambda:' before the function name with parameter in the connect method, to make it an anonymous function.

  9. what I was trying to do it have a main file for the main window while have a separate file for calling when a button is triggered. in the other file I try to change the window title when the button is pressed e.g. for button compute, the title goes "computing…" but it throws up error, it doesn't throw error when I place all of them in a single file. why?

  10. what is the difference between closing with sys.close() and QtCore.QCoreApplication.instance().quit ? It seems to me that sys.exit() might be more unexpected/traumatic to pyQt. Is it?

Leave a Reply

Your email address will not be published.

© 2022 Code As Pro - Theme by WPEnjoy · Powered by WordPress