how to initialize a QString to null?
问题 What is the difference between QString::number(0) and ((const char*) 0) ? I want to initialize a QString say phoneNumber to null . Will phoneNumber(QString::number(0)) and phoneNumber((const char*) 0) both work? 回答1: To create a null QString just default initialize it: QString phoneNumber; // or if you already have a QString variable and want to 'clear' it: phoneNumber = QString(); Note that QString::number(0) is decidedly not null - it creates a QString with the value "0" . You could also