Results 1 to 2 of 2

Thread: Qt Designer 4.4.1 Signals and Slots

  1. #1
    Join Date
    Oct 2008
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Qt Designer 4.4.1 Signals and Slots

    hi, this is my first try with PyQt so i'm trying to get a simple app to work with 1 button and 1 textbox. I tried many ways till finally get the UI to display correctly, but now i don't know where or how to define the behaviour of the button. I got the Signal/Slot thing to work with the Exit option in the menubar, but how do i define other behaviour not present in the Signal/Slot Edition window? (i think that dissapeared after Qt Designer 3.x).
    Other Questions:
    1.- What to define in the subclass? Controls (button, linEdit, combobox)? or Methods (on_button_clicked)?
    2.- How?? (Qobjedt.connect......??)
    3.- Here is my code...the main idea is just to get some text to the textbox on button_clicked(). I've read many PyQt Documentation, the reference guide, old versions docs, etc. I guess i'm the problem .

    Python Code:
    1. import sys
    2. from PyQt4.Qt import *
    3.  
    4. from ui import Ui_Main
    5.  
    6. #this is the subclass that processes idk what rlly.... :confused:
    7. class MainWindow(QMainWindow):
    8.  
    9. def __init__(self, win_parent = None):
    10. QMainWindow.__init__(self, win_parent)
    11.  
    12. #I don't think this on_boton_clicked it's correct, but it does work....:o
    13. def on_Boton_clicked(self):
    14. print "Clicked"
    15.  
    16. if __name__ == '__main__':
    17. app = QApplication(sys.argv)
    18. window = MainWindow()
    19. ui = Ui_Main()
    20. ui.setupUi(window)
    21. window.show()
    22. sys.exit(app.exec_())
    23. app.exec_loop()
    To copy to clipboard, switch view to plain text mode 

    TY in Advance.
    Last edited by wysota; 13th October 2008 at 08:19.

  2. #2
    Join Date
    Oct 2008
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qt Designer 4.4.1 Signals and Slots

    kk, so as i was drowning in a cup of water, here is the code if ne noob like me needs it.



    Qt Code:
    1. import sys
    2.  
    3. from PyQt4.Qt import *
    4. #from PyQt4 import QtGui
    5. #from PyQt4.QtCore import *
    6.  
    7. from ui import Ui_Main
    8.  
    9. def prueba():
    10. print 'as'
    11. ui.lineEdit.clear()
    12.  
    13. class MainWindow(QMainWindow, Ui_Main):
    14.  
    15. def __init__(self):
    16. QMainWindow.__init__(self)
    17. print 'asd'
    18.  
    19. def on_button_clicked(self):
    20. print 'pega'
    21. ui.lineEdit.paste()
    22.  
    23. def on_limpia_clicked(self):
    24. print 'limpia'
    25. prueba()
    26. #ui.lineEdit.clear()
    27.  
    28. if __name__ == '__main__':
    29. app = QApplication(sys.argv)
    30. ui = Ui_Main()
    31. window = MainWindow()
    32. ui.setupUi(window)
    33. window.show()
    34. sys.exit(app.exec_())
    35. app.exec_loop()
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Signals and Slots
    By 83.manish in forum Qt Programming
    Replies: 3
    Last Post: 30th June 2008, 10:31
  2. Replies: 12
    Last Post: 23rd June 2008, 08:05
  3. Problem with SpinBox signals and slots
    By ramstormrage in forum Newbie
    Replies: 4
    Last Post: 2nd May 2008, 01:45
  4. Signals and Slots Across Threads
    By themusicalguy in forum Qt Programming
    Replies: 1
    Last Post: 26th October 2007, 11:16
  5. signals and slots in plugins
    By anderl in forum Qt Programming
    Replies: 1
    Last Post: 10th October 2007, 13:57

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.