Results 1 to 12 of 12

Thread: How to connect mainwindow and dialog using signal,slot

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Dec 2012
    Posts
    197
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    25
    Thanked 41 Times in 33 Posts

    Default Re: How to connect mainwindow and dialog using signal,slot

    Hello,
    Please use code tags for better reading, viewing, and understanding of code.
    check this link Code Tags
    Qt Code:
    1. connect(ui->lineEdit, SIGNAL(textEdited(QString)), dialog, SLOT(seText(s)));
    To copy to clipboard, switch view to plain text mode 
    The signature of a signal must match the signature of the receiving slot. You cant pass a value in the connect() statement , which is in your case SLOT(seText(s))
    it should be SLOT(seText(QString)). You should always pass the signature , the type of the parameter that is passed by the signal or the slot not the string its self.
    should be :
    Qt Code:
    1. connect(ui->lineEdit, SIGNAL(textEdited(QString)), dialog, SLOT(seText(QString)));
    To copy to clipboard, switch view to plain text mode 
    Signals and slots can take any number of arguments of any type. They are completely type safe.
    you should check this link Signals and Slots.
    PS. note the difference between textEdited and textChanged
    textEdited()This signal is emitted whenever the text is edited. The text argument is the new text.
    Unlike textChanged(), this signal is not emitted when the text is changed programmatically, for example, by calling setText().


    in dialog.h
    public slots :
    void seText(QString q);
    even in the header file the slot should be seText(QString). // just a declaration
    you define the function in you .cpp file
    Good Luck.
    Last edited by toufic.dbouk; 6th October 2013 at 18:55.

  2. The following user says thank you to toufic.dbouk for this useful post:

    harvey_slash (9th October 2013)

Similar Threads

  1. Replies: 3
    Last Post: 23rd June 2013, 17:01
  2. signal slot to mainwindow
    By giugio in forum Newbie
    Replies: 3
    Last Post: 9th November 2012, 21:05
  3. Replies: 2
    Last Post: 15th September 2010, 01:54
  4. Can't connect a signal to a slot
    By cejohnsonsr in forum Newbie
    Replies: 5
    Last Post: 26th August 2010, 21:42
  5. problem connect signal - slot
    By jaca in forum Newbie
    Replies: 13
    Last Post: 9th March 2010, 20:38

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.