gpt-3.5-turbo-0613· openai
Suzhen/CodeChat
QList快速添加1到10
- User
QList快速添加1到10
- Assistant
To quickly add numbers 1 to 10 in QList, you can use the
append()function. Here's an example:#include <QList> #include <QDebug> int main() { QList<int> numbers; for (int i = 1; i <= 10; i++) { numbers.append(i); } qDebug() << numbers; return 0; }This code creates an empty QList called "numbers" and then uses a for loop to append numbers 1 to 10 to the list. Finally, it prints the contents of the list using qDebug().