Hello,

Thanks for the swift reply – sorry for not replying any sooner than I have right now.

I've put breakpoints on the entire code that I've provided above.

Oddly enough, the bool values (when it processes the first definition of isChecked() - line 3 as seen above) are:

-dio0: 128
-dio1: 188
-dio2: 106
-dio3: false

When I continue to the next definition (line 4), the values are:

-dio0: false
-dio1: same
-dio2: same
-dio3: same

Then: false, false, same same -> false, false, false, same -> false, false, false, false.

Any suggestions? I can't seem to see why it does that.

Here's the entire code of the file, in-case needed:

Qt Code:
  1. #include "etclient.h"
  2. #include "ui_etclient.h"
  3. #include "about.h"
  4.  
  5. ETClient::ETClient(QWidget *parent) :
  6. QMainWindow(parent),
  7. ui(new Ui::ETClient)
  8. {
  9. this->ui->setupUi(this);
  10.  
  11. this->connect(ui->menuAbout,SIGNAL(triggered()),this,SLOT(show_about()));
  12.  
  13. this->connect(ui->pushConnect,SIGNAL(clicked()),this,SLOT(pre_begin()));
  14. this->connect(ui->pushDisconnect,SIGNAL(clicked()),this,SLOT(close_session()));
  15. this->connect(&client,SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(connection_invalid()));
  16. this->connect(&client,SIGNAL(connected()),this,SLOT(start_transfer()));
  17.  
  18. this->ui->pushDisconnect->setShown(false);
  19. }
  20.  
  21. ETClient::~ETClient()
  22. {
  23. client.close();
  24. delete(this->ui);
  25. }
  26.  
  27. void ETClient::show_about()
  28. {
  29. About *about = new About();
  30. about->show();
  31. }
  32.  
  33. void ETClient::pre_begin()
  34. {
  35. QString device_addr = this->ui->txtbxIP->text();
  36. int device_port = this->ui->txtbxPort->text().toInt();
  37.  
  38. this->begin(device_addr,device_port);
  39. }
  40.  
  41. void ETClient::begin(QString host, quint16 port_n)
  42. {
  43. QHostAddress addr(host);
  44.  
  45. client.connectToHost(addr,port_n);
  46. }
  47.  
  48. void ETClient::start_transfer()
  49. {
  50. QString conSucc = "Connected successfully to: ";
  51. QString device_addr = this->ui->txtbxIP->text();
  52.  
  53. this->ui->txtbxIP->setText(conSucc%device_addr);
  54. this->ui->txtbxIP->setEnabled(false);
  55. this->ui->txtbxPort->setEnabled(false);
  56.  
  57. this->ui->pushConnect->setShown(false);
  58. this->ui->pushDisconnect->setShown(true);
  59.  
  60. this->ui->chkDIO0->setEnabled(true);
  61. this->ui->chkDIO1->setEnabled(true);
  62. this->ui->chkDIO2->setEnabled(true);
  63. this->ui->chkDIO3->setEnabled(true);
  64.  
  65. this->on_pushSendData_clicked();
  66. }
  67.  
  68. void ETClient::connection_invalid()
  69. {
  70. QString strInvalid = "Failed to connect. ";
  71. QString device_addr = this->ui->txtbxIP->text();
  72.  
  73. this->ui->txtbxIP->setText("Invalid IP.");
  74. this->ui->txtbxIP->isActiveWindow() == true;
  75. }
  76.  
  77. void ETClient::close_session()
  78. {
  79. QString device_addr = this->ui->txtbxIP->text();
  80.  
  81. client.abort();
  82.  
  83. this->ui->txtbxIP->setEnabled(true);
  84. this->ui->txtbxPort->setEnabled(true);
  85.  
  86. this->ui->pushDisconnect->setShown(false);
  87. this->ui->pushConnect->setShown(true);
  88.  
  89. this->ui->chkDIO0->setEnabled(false);
  90. this->ui->chkDIO1->setEnabled(false);
  91. this->ui->chkDIO2->setEnabled(false);
  92. this->ui->chkDIO3->setEnabled(false);
  93. }
  94.  
  95. void ETClient::on_pushSendData_clicked()
  96. {
  97. bool dio0 = this->ui->chkDIO0->isChecked();
  98. bool dio1 = this->ui->chkDIO1->isChecked();
  99. bool dio2 = this->ui->chkDIO2->isChecked();
  100. bool dio3 = this->ui->chkDIO3->isChecked();
  101.  
  102. if(dio0 == true) this->dio0_enabled();
  103. if(dio1 == true) this->dio1_enabled();
  104. if(dio2 == true) this->dio2_enabled();
  105. if(dio3 == true) this->dio3_enabled();
  106. else;
  107. }
  108.  
  109. /*
  110.   *
  111.   * DIO management functions (DIO 0,1,2,3 ENABLED & DISABLED)
  112.   *
  113.   */
  114.  
  115. void ETClient::dio0_enabled()
  116. {
  117. int nullptr = 0;
  118. QByteArray bytes;
  119.  
  120. bytes.push_back(2); // command number
  121. bytes.push_back(2); // version
  122. bytes.push_back(nullptr); // byte used for response
  123. bytes.push_back(3); // data length
  124. bytes.push_back(nullptr); // DIO number (0 = 1ste, 1 = 2de, 2 = 3de, 3 = 4de)
  125. bytes.push_back(1); // i/o mode (0 input, 1 output)
  126. bytes.push_back(nullptr); // signal (0 = aan, 1 = uit)
  127.  
  128. client.write(bytes);
  129. }
  130.  
  131. void ETClient::dio1_enabled()
  132. {
  133. int nullptr = 0;
  134. QByteArray bytes;
  135.  
  136. bytes.push_back(2); // command number
  137. bytes.push_back(2); // version
  138. bytes.push_back(nullptr); // byte used for response
  139. bytes.push_back(3); // data length
  140. bytes.push_back(1); // DIO number
  141. bytes.push_back(1); // i/o mode (0 input, 1 output)
  142. bytes.push_back(nullptr); // signal (0, 1)
  143.  
  144. client.write(bytes);
  145. }
  146.  
  147. void ETClient::dio2_enabled()
  148. {
  149. int nullptr = 0;
  150. QByteArray bytes;
  151.  
  152. bytes.push_back(2); // command number
  153. bytes.push_back(2); // version
  154. bytes.push_back(nullptr); // byte used for response
  155. bytes.push_back(3); // data length
  156. bytes.push_back(2); // DIO number
  157. bytes.push_back(1); // i/o mode (0 input, 1 output)
  158. bytes.push_back(nullptr); // signal (0, 1)
  159.  
  160. client.write(bytes);
  161. }
  162.  
  163. void ETClient::dio3_enabled()
  164. {
  165. int nullptr = 0;
  166. QByteArray bytes;
  167.  
  168. bytes.push_back(2); // command number
  169. bytes.push_back(2); // version
  170. bytes.push_back(nullptr); // byte used for response
  171. bytes.push_back(3); // data length
  172. bytes.push_back(3); // DIO number
  173. bytes.push_back(1); // i/o mode (0 input, 1 output)
  174. bytes.push_back(nullptr); // signal (0, 1)
  175.  
  176. client.write(bytes);
  177. }
  178.  
  179.  
  180. void ETClient::dio0_disabled()
  181. {
  182. int nullptr = 0;
  183. QByteArray bytes;
  184.  
  185. bytes.push_back(2); // command number
  186. bytes.push_back(2); // version
  187. bytes.push_back(nullptr); // byte used for response
  188. bytes.push_back(3); // data length
  189. bytes.push_back(nullptr); // DIO number
  190. bytes.push_back(1); // i/o mode (0 input, 1 output)
  191. bytes.push_back(1); // signal (0, 1)
  192.  
  193. client.write(bytes);
  194. }
  195.  
  196. void ETClient::dio1_disabled()
  197. {
  198. int nullptr = 0;
  199. QByteArray bytes;
  200.  
  201. bytes.push_back(2); // command number
  202. bytes.push_back(2); // version
  203. bytes.push_back(nullptr); // byte used for response
  204. bytes.push_back(3); // data length
  205. bytes.push_back(1); // DIO number
  206. bytes.push_back(1); // i/o mode (0 input, 1 output)
  207. bytes.push_back(1); // signal (0, 1)
  208.  
  209. client.write(bytes);
  210. }
  211.  
  212. void ETClient::dio2_disabled()
  213. {
  214. int nullptr = 0;
  215. QByteArray bytes;
  216.  
  217. bytes.push_back(2); // command number
  218. bytes.push_back(2); // version
  219. bytes.push_back(nullptr); // byte used for response
  220. bytes.push_back(3); // data length
  221. bytes.push_back(2); // DIO number
  222. bytes.push_back(1); // i/o mode (0 input, 1 output)
  223. bytes.push_back(1); // signal (0, 1)
  224.  
  225. client.write(bytes);
  226. }
  227.  
  228. void ETClient::dio3_disabled()
  229. {
  230. int nullptr = 0;
  231. QByteArray bytes;
  232.  
  233. bytes.push_back(2); // command number
  234. bytes.push_back(2); // version
  235. bytes.push_back(nullptr); // byte used for response
  236. bytes.push_back(3); // data length
  237. bytes.push_back(3); // DIO number
  238. bytes.push_back(1); // i/o mode (0 input, 1 output)
  239. bytes.push_back(1); // signal (0, 1)
  240.  
  241. client.write(bytes);
  242. }
To copy to clipboard, switch view to plain text mode 

Thanks for your time!