pbutler
unread,Apr 2, 2012, 2:10:01 PM4/2/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to lqt-bindings
I'm trying to understand why I can add a slot to a QTcpSocket when I
create the socket using QTcpSocket.new() but not when I get one
returned from a listening server socket.
__addmethod() seems to work correctly in the first case, however it
doesn't add the method in the second case.
What is the correct way to do this?
require "qtcore"
require "qtnetwork"
sock1 = QTcpSocket.new()
sock1:__addmethod('gotsome()', function() print('got some!') end)
table.foreachi(sock1:__methods(), print)
1 destroyed(QObject*) Protected Signal
2 destroyed() Protected Signal
3 deleteLater() Public Slot
4 _q_reregisterTimers(void*) Private Slot
5 readyRead() Protected Signal
6 bytesWritten(qint64) Protected Signal
7 aboutToClose() Protected Signal
8 readChannelFinished() Protected Signal
9 hostFound() Protected Signal
10 connected() Protected Signal
11 disconnected() Protected Signal
12 stateChanged(QAbstractSocket::SocketState) Protected Signal
13 error(QAbstractSocket::SocketError) Protected Signal
14 proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)
Protected Signal
15 connectionClosed() Protected Signal
16 delayedCloseFinished() Protected Signal
17 connectToHostImplementation(QString,quint16,OpenMode) Protected
Slot
18 connectToHostImplementation(QString,quint16) Protected Slot
19 disconnectFromHostImplementation() Protected Slot
20 _q_connectToNextAddress() Private Slot
21 _q_startConnecting(QHostInfo) Private Slot
22 _q_abortConnectionAttempt() Private Slot
23 _q_testConnection() Private Slot
24 _q_forceDisconnect() Private Slot
25 gotsome() Public Slot
addr = QHostAddress('192.168.145.151')
port = 44412
server = QTcpServer()
server:listen(addr, port)
server:waitForNewConnection(-1)
sock2 = server:nextPendingConnection()
sock2:__addmethod('gotsome()', function() print('got some!') end)
table.foreachi(sock2:__methods(), print)
1 destroyed(QObject*) Protected Signal
2 destroyed() Protected Signal
3 deleteLater() Public Slot
4 _q_reregisterTimers(void*) Private Slot
5 readyRead() Protected Signal
6 bytesWritten(qint64) Protected Signal
7 aboutToClose() Protected Signal
8 readChannelFinished() Protected Signal
9 hostFound() Protected Signal
10 connected() Protected Signal
11 disconnected() Protected Signal
12 stateChanged(QAbstractSocket::SocketState) Protected Signal
13 error(QAbstractSocket::SocketError) Protected Signal
14 proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)
Protected Signal
15 connectionClosed() Protected Signal
16 delayedCloseFinished() Protected Signal
17 connectToHostImplementation(QString,quint16,OpenMode) Protected
Slot
18 connectToHostImplementation(QString,quint16) Protected Slot
19 disconnectFromHostImplementation() Protected Slot
20 _q_connectToNextAddress() Private Slot
21 _q_startConnecting(QHostInfo) Private Slot
22 _q_abortConnectionAttempt() Private Slot
23 _q_testConnection() Private Slot
24 _q_forceDisconnect() Private Slot