I have 2 threads now
(1) a thread that leavess the main mechanism of the program in its own thread so events can take place in the new QThread thread. We solved this problem in another thread last week. At that time I was doing non-model posts to a QListWidget. I am now getting "stuff" in the QListWidget(I've learned doesn't do MVC)
(2) one model of tcpip/tcp requires (as a concurrent server) a thread to handle each client that "calls" in!
Each thread handles each client. Prior to Qt 4 I was using a Posix thread that has worked flawlessly for years! I scrapped the Posix thread and am now using QThread everywhere!
In any case, I am learning a lot. I like the MVC and am also reading along with practice!
Thanks for your patience!
Remember the MVC example you sent??? Well I incorporated it into my tcpip startup to see if at least it would generate some display! It hasn't yet!
public:
model = m;
}
protected:
}
private:
};
class Inserter : public QObject {
public:
Inserter(QStandardItemModel *m) : QObject() {
model = m;
}
protected:
void timerEvent(QTimerEvent *e){
QString str = QDateTime::currentDateTime().toString();
model->appendRow(new QStandardItem(str));
}
private:
QStandardItemModel *model;
};
To copy to clipboard, switch view to plain text mode
Timer thing didn't work either:
void tcpip::StartTCPServer()
{
ui.
listWidgetServer->addItem
(QString("server1 StartTCPServer"));
ui.listViewServer->setModel(model);
model->setColumnCount(1);
bool ok = true;
QString qstr
= ui.
lineEditTCPIPServerPortServer->text
();
port = qstr.toInt(&ok);
//qDebug()<<" server port "<<port;
ui.lineEditServerStatus->setText("server started");
tcpipThread* ptcpipThreadStart = new tcpipThread(ui, port, this);
ptcpipThreadStart->start();
Inserter ins(model);
ins.startTimer(1000);
}
void tcpip::StartTCPServer()
{
ui.listWidgetServer->addItem(QString("server1 StartTCPServer"));
ui.listViewServer->setModel(model);
model->setColumnCount(1);
QString str("landon is first");
model->appendRow(new QStandardItem(str));
QString str2("landon is second");
model->appendRow(new QStandardItem(str2));
QApplication::processEvents();
bool ok = true;
QString qstr = ui.lineEditTCPIPServerPortServer->text();
port = qstr.toInt(&ok);
//qDebug()<<" server port "<<port;
ui.lineEditServerStatus->setText("server started");
QApplication::processEvents();
tcpipThread* ptcpipThreadStart = new tcpipThread(ui, port, this);
ptcpipThreadStart->start();
Inserter ins(model);
ins.startTimer(1000);
}
To copy to clipboard, switch view to plain text mode
public:
model = m;
}
protected:
qDebug()<<"hello";
}
private:
};
class Inserter : public QObject {
public:
Inserter(QStandardItemModel *m) : QObject() {
model = m;
}
protected:
void timerEvent(QTimerEvent *e){
QString str("hello");
model->appendRow(new QStandardItem(str));
qDebug()<<"hello";
}
private:
QStandardItemModel *model;
};
To copy to clipboard, switch view to plain text mode
Bookmarks