Results 1 to 6 of 6

Thread: slots with arguments

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2011
    Posts
    31
    Thanks
    23
    Qt products
    Qt4
    Platforms
    Windows

    Default slots with arguments

    is this legal? I can compile but i wonder if this is bad practice or, even worse, suited for run time bugs
    Qt Code:
    1. connect(mTcpSocket, SIGNAL(connected()), this, SLOT(sendMsg(mTcpSocket)));
    2.  
    3. connect(pTcpSocket, SIGNAL(connected()), this, SLOT(sendMsg(pTcpSocket)));
    4. ...
    5. void ecmqMfgClient::sendMsg(QTcpSocket *tcpSocket)
    6. {
    7. QByteArray block;
    8. QDataStream out(&block, QIODevice::WriteOnly);
    9. out.setVersion(QDataStream::Qt_4_1);
    10. out << this->Cli2SvrMsg.dutId;
    11. out << this->Cli2SvrMsg.opCode;
    12. out.device()->seek(0);
    13. tcpSocket->write(block);
    14. tcpSocket->waitForBytesWritten();
    15.  
    16. }
    To copy to clipboard, switch view to plain text mode 
    i.e. can i associate to the same signal of two different QTcpSocket to the same slot but with different parameters (the target socket but also others)?
    QTcpSocket is event driven so i do not see any danger for concurrency, right?

    not sure this is really a newbie question, hope to get less severe reply from somebody ;-)

    thanks much
    Last edited by marco.stanzani; 23rd March 2011 at 11:29.

Similar Threads

  1. QApplication Arguments
    By ToddAtWSU in forum Qt Programming
    Replies: 0
    Last Post: 27th January 2011, 16:34
  2. how to use arguments in Qt?
    By mr_kazoodle in forum Newbie
    Replies: 5
    Last Post: 26th January 2011, 20:04
  3. QProcess Arguments
    By doggrant in forum Qt Programming
    Replies: 0
    Last Post: 4th November 2010, 16:45
  4. QVector arguments
    By phillip_Qt in forum Qt Programming
    Replies: 2
    Last Post: 4th December 2007, 10:47
  5. Replies: 1
    Last Post: 6th April 2006, 12:24

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.