Results 1 to 5 of 5

Thread: Basically signals-slot application

  1. #1
    Join Date
    May 2010
    Posts
    46
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Lightbulb Basically signals-slot application

    Hi,
    i have a problem.
    I have an application whit 6 different lineEdit. Each lineedit rapresent a field of my personal database.

    The goal is:
    when the text in a lineEdt is modify i would writing the new value on my database.
    For solve this task i have create a signal-slot architecture: i have connected the signal "editingFinished" whit my personal slot.

    The problem is that in the application there are 6 different lineEdit that can emit "editingFinished".

    How i can recognize a specific lineEdit? I have try using the sender() function but my object that emit this signal is all lineEdit.

    Can anyone help me, please???

    Thanks!
    Dax

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Basically signals-slot application

    Quote Originally Posted by Daxos View Post
    How i can recognize a specific lineEdit? I have try using the sender() function but my object that emit this signal is all lineEdit.
    Example:
    Qt Code:
    1. QLineEdit *theSendingLineEdit = static_cast<QLineEdit*>(sender());
    To copy to clipboard, switch view to plain text mode 

    But I suggest you look into QSignalMapper

  3. #3
    Join Date
    May 2010
    Posts
    46
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Basically signals-slot application

    Quote Originally Posted by tbscope View Post
    Example:
    Qt Code:
    1. QLineEdit *theSendingLineEdit = static_cast<QLineEdit*>(sender());
    To copy to clipboard, switch view to plain text mode 

    But I suggest you look into QSignalMapper
    Ok thaks, but i have another problem:

    Fro example assume that i have this situation:
    first LineEdit: Name
    second LineEdit: Surname

    Both the value of the linEdit is QString.

    Whit this method i have the current lineEdit that have emitted the signal, but i don't know if is the linEdit Surname or the lineEdit Name. But this is very important for me because i want save the lineEdit's value in my database

  4. #4
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Basically signals-slot application

    QSignalMapper will tell you exactly which widget it is.
    Check out the examples

  5. #5
    Join Date
    May 2010
    Posts
    46
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Basically signals-slot application

    Ok thanks for the reply!!!

Similar Threads

  1. Many signals one slot
    By ^Nisok^ in forum Newbie
    Replies: 7
    Last Post: 18th April 2009, 15:05
  2. signals and slot...can i select my option ?
    By salmanmanekia in forum Qt Programming
    Replies: 8
    Last Post: 7th August 2008, 11:44
  3. [Basic question] Signals & Slot
    By GortiZ in forum Newbie
    Replies: 5
    Last Post: 1st April 2008, 10:39
  4. many signals, one slot
    By eric in forum Qt Programming
    Replies: 5
    Last Post: 24th January 2008, 07:25
  5. Signals and slot
    By rajeshclt3 in forum Newbie
    Replies: 1
    Last Post: 29th November 2007, 12:41

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.