Results 1 to 10 of 10

Thread: pushbutton action

  1. #1
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default pushbutton action

    Hi, I have linked a button to this SLOT;it's a toggled button in a exclusive toolbar button;
    If my button is down and if I click again on it, the putton is down again (OK), but start SLOT and it executes "emit (setEdit(0));" I don't want this; my button is down still; sould it executes the first part of 'if'? Thanks

    Qt Code:
    1. void MainForm::zoomingIn( bool pressed )
    2. {
    3. if (pressed) {
    4. printf("zoomIN\n");
    5. emit (setEdit(3));
    6. }
    7. else {
    8. emit (setEdit(0));
    9. }
    10. }
    To copy to clipboard, switch view to plain text mode 
    Regards

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: pushbutton action

    What signal did you connect it to?

  3. #3
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: pushbutton action

    the signal connected to this SLOT is toggled(bool).
    Regards

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: pushbutton action

    You should probably try with stateChanged(int) signal. This will not trigger the slot if you click on an already depressed button. I guess toggled() shouldn't be emitted too, but looks like it is...

  5. #5
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: pushbutton action

    sorry, but this signal is from Designer; and the possiblity are: toggled(bool) and activated()....??
    Regards

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: pushbutton action

    I have a stateChanged(int) signal in Designer. You're trying to connect to a slot taking a bool parameter, so Designer hid signals which don't match the signature. Change the slot signature and Designer will show you the stateChanged(int) signal.

  7. #7
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: pushbutton action

    sorry, I have deleted the SLOT from desinger, but when I choose action zoomIn, in the signal appears only two above; I remember that toggleAction on this action is 'true';
    don't I undestand?
    Regards

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: pushbutton action

    The signal surely is there. It's present since Qt 3.0 so it's not the matter of version... You can take a look at the docs: QButton::stateChanged(int). Try some other way of connecting the signal or attach the ui file here and I will make that connection for you.

    EDIT: What do you mean "action ZoomIn"? You said you were connecting a button, not an action... I am talking about connecting the button's stateChanged signal to some signal/slot (whatever it is, be it even the action's activated() signal).

  9. #9
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: pushbutton action

    sorry, it isn't a button; is an ACTION!!! (changeState(int) signal there is; but ie for spinBox.....)
    Regards

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: pushbutton action

    So maybe it's better to connect to the action group directly?

    You could use the selected(QAction*) signal then and act upon the action which was chosen.

  11. The following user says thank you to wysota for this useful post:

    mickey (21st April 2006)

Similar Threads

  1. QTreeView default drag action
    By onamatic in forum Qt Programming
    Replies: 2
    Last Post: 1st March 2010, 07:37
  2. Replies: 12
    Last Post: 21st November 2008, 04:42
  3. Problem with setFont for a PushButton
    By arunvv in forum Newbie
    Replies: 12
    Last Post: 7th April 2008, 23:35
  4. connecting image to a pushbutton
    By sudheer in forum Qt Tools
    Replies: 2
    Last Post: 4th December 2007, 09:23
  5. No action checked in an exclusive action group
    By SkripT in forum Qt Programming
    Replies: 12
    Last Post: 13th February 2006, 06:19

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.