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:

Qt Code:
  1. // assuming QString tmp holds the complete line (i.e. "/join #qt")
  2. // detect '/' followed by an alphanumeric string followed by a whitespace followed by some other text
  3. QRegExp commandRx("^/([A-Za-z][A-Za-z0-0]+)\\s(.*)$");
  4. if(commandRx.exactMatch(tmp)){
  5. // we have found a command
  6. QString cmdName = commandRx.cap(1); // command name (first set of brackets)
  7. QString arguments = commandRx.cap(2); // everything past the space (second set of brackets)
  8. cmdName = cmdName.toLower();
  9. if(cmdName == "join") {
  10. QStringList channels = arguments.split(" "); // split on spaces
  11. foreach(QString channel, channels) {
  12. if(channel.startsWith("#")) {
  13. joinChannel(channel.mid(1)); // join everything starting with '#'
  14. }
  15. }
  16. } else if(cmdName == ... ) {
  17. ...
  18. } ...
  19. }
To copy to clipboard, switch view to plain text mode