Results 1 to 13 of 13

Thread: cannot write to QListWidget or QLineEdit

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2008
    Posts
    38
    Thanks
    19
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default cannot write to QListWidget or QLineEdit

    I have isolated the problem as follows:

    I have some old old code for a TCP/IP server.

    I cannot use QTCPIPServer or any Qt network programs!

    I must use Qt 4 designer to make a gui to communicate with the TCP/IP server!

    I press a button and a slot program calls the TCP/IP constructor.

    The TCP/IP constructor calls the usual socket, bing, listen accept.

    The program continues to work as a server but the code to write to a QListWidget or QLineEdit object does not work.

    I've even tried putting the constructor in its own thread.

    I've tried various placements of QApplication::processEvents();

    Qt Code:
    1. #include "tcpip.h"
    2. #include "tcpip_server.cpp"
    3. #include "tcpip_client.cpp"
    4. #include <iostream>
    5. //#include <QtDebug>
    6. tcpip::tcpip(QWidget *parent)
    7. : QWidget(parent)
    8. {
    9. ui.setupUi(this);
    10. connect( ui.pushButtonStartTCPServer, SIGNAL(clicked()), this, SLOT(StartTCPServer()) );
    11. connect( ui.pushButtonStartTCPClient, SIGNAL(clicked()), this, SLOT(StartTCPClient()) );
    12.  
    13. ui.listWidgetServer->addItem(QString("server constructor")); ///works here
    14.  
    15. }
    16.  
    17. tcpip::~tcpip()
    18. {
    19. }
    20. void tcpip::StartTCPServer()
    21. {
    22. ui.listWidgetServer->addItem(QString("server StartTCPServer")); // not here
    23.  
    24. // QApplication::processEvents();
    25. bool ok = true;
    26. QString qstr = ui.lineEditTCPIPServerPortServer->text();
    27. port = qstr.toInt(&ok);
    28. //qDebug()<<" server port "<<port;
    29. ui.lineEditServerStatus->setText("server started");
    30.  
    31. QApplication::processEvents();
    32.  
    33. tcpipThread tcpipThreadStart(ui, port);
    34. tcpipThreadStart.run();
    35. tcpipThreadStart.wait(ULONG_MAX);
    36.  
    37. }
    38. void tcpip::StartTCPClient()
    39. {
    40. ui.listWidgetClient->addItem(QString("client StartTCPClient"));
    41. bool ok = true;
    42. QString qstr = ui.lineEditTCPIPServerPortClient->text();
    43.  
    44. //QApplication::processEvents();
    45. ushort port = qstr.toInt(&ok);
    46. //qDebug()<<"client port = "<<port;
    47. tcpip_client* p_client = new tcpip_client((int)19999,port,FALSE, ui);
    48.  
    49. str_client(p_client, ui); /* process the request */
    50. close();
    51. }
    52.  
    53.  
    54. }
    55. void tcpip::currChanged(QWidget*){};
    56.  
    57. void tcpipThread::run()
    58. {
    59. tcpip_server* p_serv = new tcpip_server((int)19999,port,tcpip_server::str_echo, ui);
    60. qDebug()<<"oops...back from CTOR";
    61. delete p_serv;
    62. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 11th August 2008 at 21:25. Reason: missing [code] tags

Similar Threads

  1. Pointer Question related to QLineEdit
    By ChrisReath in forum Qt Programming
    Replies: 1
    Last Post: 23rd May 2008, 15:13
  2. QValidator, regular expressions and QLineEdit
    By hvengel in forum Qt Programming
    Replies: 1
    Last Post: 8th August 2007, 01:25
  3. Replies: 13
    Last Post: 15th December 2006, 11:52

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.