Results 1 to 8 of 8

Thread: Any way to force a signal?

  1. #1
    Join Date
    Oct 2008
    Posts
    74
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Any way to force a signal?

    Hi

    I would like to force a set signals (from combo boxes and spinboxes) to call slots in my application even though the indices have not changed. Is this possible?

    Best regards

  2. #2
    Join Date
    Sep 2007
    Location
    Rome, GA
    Posts
    199
    Thanks
    14
    Thanked 41 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Any way to force a signal?

    Yes. Just create your own signals and emit them whenever you want.

  3. #3
    Join Date
    Oct 2008
    Posts
    74
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Any way to force a signal?

    Can I do this with QComboBox and QSpinBox?

    e.g

    emit iterSpinBox->valueChanged(DEFAULT_ITERS);

    gives me a compile error "is protected withinn this context"
    Last edited by dbrmik; 13th March 2009 at 15:01. Reason: updated contents

  4. #4
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Any way to force a signal?

    Hi,

    SLOTs are functions, so call it directly.
    Òscar Llarch i Galán

  5. #5
    Join Date
    Sep 2007
    Location
    Rome, GA
    Posts
    199
    Thanks
    14
    Thanked 41 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Any way to force a signal?

    Yes, just like ^NyAw^ says, a slot is just a function so you actually don't need signals. Here is an example:
    Qt Code:
    1. int combo_index = myComboBox->currentIndex();
    2. mySlot(combo_index);
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Oct 2008
    Posts
    74
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Any way to force a signal?

    Thanks Jim,

    I thought there might be a way of setting values in my comboxboxes which would force an automatic call to my slots. This happens if the index values change from their defaults but not if they remain the same
    Last edited by dbrmik; 13th March 2009 at 15:17. Reason: updated contents

  7. #7
    Join Date
    Sep 2007
    Location
    Rome, GA
    Posts
    199
    Thanks
    14
    Thanked 41 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Any way to force a signal?

    You ought to post your code, but as long as your connections are made before you do whatever you are doing in SetDefaults() then the signals should be properly emitted.

  8. #8
    Join Date
    Oct 2008
    Posts
    74
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Any way to force a signal?

    Thanks Jim, ^NyAw^

    Yes, the connections are made before setDefaults() is called. I suppose what I was looking for is a way to propogate the settings of my spinboxes to MyClass even if their values have not changed ( I am now called the slots directly)

    Thanks for your time

Similar Threads

  1. pthread instead QThread
    By brevleq in forum Qt Programming
    Replies: 8
    Last Post: 23rd December 2008, 07:16
  2. Connection of custon signals/slots
    By brevleq in forum Qt Programming
    Replies: 2
    Last Post: 23rd December 2008, 07:04
  3. nmake problems while building mysql driver
    By MarkoSan in forum Installation and Deployment
    Replies: 27
    Last Post: 25th May 2007, 12:57
  4. QT4 beginner Fatal Error
    By Remyfr in forum Installation and Deployment
    Replies: 3
    Last Post: 11th March 2006, 01:48

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.