its to append a text in the "read" text edit
its to append a text in the "read" text edit
If you have still problems with the crash, put your code into a zip file and attach it to your post and I'll see what the problem is.
Well, the printText is a function in the "Channel" class when calling it from the "MainWindow" class it doesnt print text in the "read" textEdit, heres what printText supposed to do:
Qt Code:
void Channel::printText(const QString& text) { read->append(text); }To copy to clipboard, switch view to plain text mode
Qt Code:
Channel* chan = new Channel(this, channel.c_str(), socket); chan->printText(tmp);To copy to clipboard, switch view to plain text mode
I guess that's because you create that C-style string pointer, if you want to create a QString from a std::string don't use the .c_str() method, use the static member function of QString fromStdString() (this create a copy of the string)
It has been said: it's better if you use QString instead std::string (and C-style strings)
thats what written in there:
Qt Code:
:stockholm.se.quakenet.org 366 Fallen_ #Fallen :End of /NAMES list. [00:45:51] Fallen_ has joined #FallenTo copy to clipboard, switch view to plain text mode
using qDebug()?
ive showed u 2 lines already, the problem is not the lines....
Last edited by wysota; 19th September 2010 at 23:21. Reason: Removed improper words
Look - programs are a compendium of statements that operate on data. If you're having a problem, it can only be in one of two places - the statements, or the data those statements operate on.
You've been asked to print out the strings your program makes use of - not just the input strings, but the strings after you've gotten done munging around with them. The strings that you feed to your program statements. If the input data is wrong (and frankly, this seems likely, given that you're attempting to transform between three different string manipulation libraries) then your statements aren't going to produce the results you expect.
So far, in two full pages, you've produced the single, top-level input string, but none of what was actually asked for.
Also, although many people frown upon it, "printf-style" debugging is often a fast, efficient means to find out what's wrong with your program. Yes, a debugger will usually get you there faster. But especially when working with potentially corrupt strings, simply dumping those strings to a console often provides you (or those you're asking to do your work for you) valuable clues about what the problem may actually be.
You've also refused to produce code, despite a number of such requests.
If you can't play along, figure it out for yourself; you've been given far more than enough guidance to do so. If, however, you want others to help you, you're going to have to respond fully and accurately - and politely - when those you're asking for help request additional information.
Qt Code:
void MainWindow::appendToWindow() { char buffer[1024], tmp[1024]; while(socket->canReadLine()) { socket->readLine(buffer, sizeof(buffer)); std::string str = buffer; std::string name = getName(buffer), msg = getMsg(buffer), channel = getChannel(buffer), t = getTime(); if(connected) { if(str.substr(0, 4) == "PING") { std::string s = "PO" + str.substr(2) + "\r\n"; socket->write(s.c_str()); } else if(str.find("PRIVMSG") != std::string::npos) sprintf(tmp, "%s <%s>(%s) %s", t.c_str(), name.c_str(), channel.c_str(), msg.c_str()); else if(str.find("NOTICE") != std::string::npos) sprintf(tmp, "%s Notice from: %s Message: %s", t.c_str(), name.c_str(), msg.c_str()); else if(str.find("JOIN") != std::string::npos) sprintf(tmp, "%s %s has joined %s", t.c_str(), name.c_str(), channel.c_str()); else if(str.find("PART") != std::string::npos) sprintf(tmp, "%s %s has left %s (%s)", t.c_str(), name.c_str(), channel.c_str(), msg.c_str()); else if(str.find("QUIT") != std::string::npos) sprintf(tmp, "%s %s has quit (%s)", t.c_str(), name.c_str(), msg.c_str()); else read->append(buffer); read->append(tmp); } } }To copy to clipboard, switch view to plain text mode
it had it, but i removed it since its not needed but the lines are 26-28 (read->append(tmp) is the read text edit from the MainWindow so i know that theres still text))
In that case I have no idea what you want. From what I understood from post #23 you said read->append(tmp) didn't work. So what's the problem exactly? Try to be as specific and clear as you can.
Bookmarks