Could you print the value of buffer before calling the constructor?
By the way, if you want to extract the argument to your "/join" command, you can do it this way:
// assuming QString tmp holds the complete line (i.e. "/join #qt")
// detect '/' followed by an alphanumeric string followed by a whitespace followed by some other text
QRegExp commandRx
("^/([A-Za-z][A-Za-z0-0]+)\\s(.*)$");
if(commandRx.exactMatch(tmp)){
// we have found a command
QString cmdName
= commandRx.
cap(1);
// command name (first set of brackets) QString arguments
= commandRx.
cap(2);
// everything past the space (second set of brackets) cmdName = cmdName.toLower();
if(cmdName == "join") {
QStringList channels
= arguments.
split(" ");
// split on spaces foreach
(QString channel, channels
) { if(channel.startsWith("#")) {
joinChannel(channel.mid(1)); // join everything starting with '#'
}
}
} else if(cmdName == ... ) {
...
} ...
}
// assuming QString tmp holds the complete line (i.e. "/join #qt")
// detect '/' followed by an alphanumeric string followed by a whitespace followed by some other text
QRegExp commandRx("^/([A-Za-z][A-Za-z0-0]+)\\s(.*)$");
if(commandRx.exactMatch(tmp)){
// we have found a command
QString cmdName = commandRx.cap(1); // command name (first set of brackets)
QString arguments = commandRx.cap(2); // everything past the space (second set of brackets)
cmdName = cmdName.toLower();
if(cmdName == "join") {
QStringList channels = arguments.split(" "); // split on spaces
foreach(QString channel, channels) {
if(channel.startsWith("#")) {
joinChannel(channel.mid(1)); // join everything starting with '#'
}
}
} else if(cmdName == ... ) {
...
} ...
}
To copy to clipboard, switch view to plain text mode
Bookmarks