Results 1 to 12 of 12

Thread: QtTableWidget to fire of a function

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2016
    Location
    Venice, California
    Posts
    87
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    7

    Default Re: QtTableWidget to fire of a function

    I think I'm confusing myself. Hahaha I'm watching Qt C++ vids on YouTube and trying to find the equivalent in PyQt/PySide.
    I apologize.
    Let me start again:
    I have a function. Same one above, myPrint()

    Using the non signal method, this works:
    ui.pushbutton1.clicked.connect(myPrint())

    Now I'm trying to see if I can get it using Signals&Slots.
    This doesn't work.
    connect(ui.pushbutton1, SIGNAL(clicked()), ui.pushbutton1, SLOT(myPrint()))
    Neither does this...
    connect(ui.pushbutton1, SIGNAL(clicked()), myPrint())

    What is the correct syntax?

    Thanks!

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: QtTableWidget to fire of a function

    Quote Originally Posted by Nfrancisj View Post
    I
    Using the non signal method, this works:
    ui.pushbutton1.clicked.connect(myPrint())
    If that works, why not use it?

    Quote Originally Posted by Nfrancisj View Post
    I
    Now I'm trying to see if I can get it using Signals&Slots.
    This doesn't work.
    connect(ui.pushbutton1, SIGNAL(clicked()), ui.pushbutton1, SLOT(myPrint()))
    myPrint is not a function of pushbutton1, right?

    Quote Originally Posted by Nfrancisj View Post
    I
    Neither does this...
    connect(ui.pushbutton1, SIGNAL(clicked()), myPrint())
    There is no SLOT() in this line.

    You might also have to specify "self" as the receiver object.

    Cheers,
    _

  3. #3
    Join Date
    Feb 2016
    Location
    Venice, California
    Posts
    87
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    7

    Default Re: QtTableWidget to fire of a function

    Quote Originally Posted by anda_skoa View Post
    If that works, why not use it?
    _
    There are something's easier in slot method. I'm just trying to learn all the possibles just to be flexible.

    Quote Originally Posted by anda_skoa View Post
    There is no SLOT() in this line.
    _
    That's what I thought when I saw this: @time 13:32, Line 23
    http://youtu.be/0vvb7Kv59qA


    Then I tried it in my script, and it didn't work. I even duplicated the setup he has. I used QtDesigner instead of writing it out,but I can't seem to understand what he is doing different to make line 23 work.

    Hahaha, there's another guy in Spain, I'm trying to find his video again, who does Signals and slots in a different way also. He uses some weird syntax.

    By the way, I'm not doing any projects or anything. just studying QT in my spare time. and I thank you very much, again, for helping me understand things.

    cheers!

  4. #4
    Join Date
    Feb 2016
    Location
    Venice, California
    Posts
    87
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    7

    Default Re: QtTableWidget to fire of a function

    I figured it out. I need to write it this way:

    QtCore.QObject.connect(self.myButton, QtCore.SIGNAL('clicked()'), myFunction)

    The clouds have cleared, and now everything hooks up well.

Similar Threads

  1. QSocketNorifier on stdin dont fire signal WinXP
    By dexli in forum Qt Programming
    Replies: 2
    Last Post: 11th December 2013, 10:38
  2. Signal is emtted, slot does not fire.
    By JasonKretzer in forum Newbie
    Replies: 3
    Last Post: 1st August 2013, 21:40
  3. QSqlTableModel OnFieldChange causes what signal to fire?
    By scott_hollen in forum Qt Programming
    Replies: 0
    Last Post: 27th September 2011, 20:23
  4. fire and forget way for QProcess
    By qt_gotcha in forum Newbie
    Replies: 2
    Last Post: 17th August 2010, 19:42
  5. QObject::connect exception fire
    By names in forum Qt Programming
    Replies: 1
    Last Post: 18th April 2010, 07:59

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.