Page 2 of 2 FirstFirst 12
Results 21 to 24 of 24

Thread: Passing strings to SLOT function

  1. #21
    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: Passing strings to SLOT function

    Could you elaborate on what you mean by "unable to receive the string"? Which code runs, which does not?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  2. #22
    Join Date
    May 2012
    Posts
    21
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Passing strings to SLOT function

    Seems good now, I tested it with qdebug, and it was able to print out the emitted string. Sorry for the confusion.

    I was wondering is it possible to use qdebug or something equivalent and use the message.toStdString with getline to use the emitted string as an input(cin)?
    Correct me if I'm wrong about this, am I correct to say that qdebug can only be used for cout and not cin? On the other hand, if I'm using string string_in = message.toStdString(); as suggested, the app doesn't seem to be able to take the emitted string and do what it needs to do. The app just sits there waiting for an input, which it never gets when the pushbutton is clicked.

    Also, I've tried using
    QTextStream qtin(stdin);
    qtin >> message;
    doesn't seem to work.
    Last edited by ashboi; 11th September 2013 at 15:13.

  3. #23
    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: Passing strings to SLOT function

    For debug is for debugging output. If you don't want to use cin, you can use QTextStream with stdin. I assure you it works, apparently you're using it wrong.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    Default Re: Passing strings to SLOT function

    Quote Originally Posted by ashboi View Post
    The app just sits there waiting for an input, which it never gets when the pushbutton is clicked.
    You have two types of input: one through the button and the signal, one through reading from cin. The latter will of course block until it can read something from stdin.

    Or did you mean it is hanging somewhere else?

    Cheers,
    _

Similar Threads

  1. Passing argument to slot.
    By TCB13 in forum Newbie
    Replies: 2
    Last Post: 22nd February 2012, 20:52
  2. Passing data via signal/slot
    By gib in forum Qt Programming
    Replies: 4
    Last Post: 1st November 2010, 06:49
  3. Passing an integer to a slot
    By bizmopeen in forum Newbie
    Replies: 6
    Last Post: 30th October 2009, 10:51
  4. Passing QsqlRecords in a function
    By ambarish_singh in forum Qt Programming
    Replies: 7
    Last Post: 13th August 2009, 12:10
  5. passing arguments in SLOT
    By eleanor in forum Qt Programming
    Replies: 3
    Last Post: 3rd July 2008, 22:55

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.