⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shoppinglist-test.cpp

📁 压缩包里有教材<<C++模式设计-基于QT4开源跨平台开发框架>>所有源码
💻 CPP
字号:
#include <QInputDialog>#include <QMessageBox>#include <QApplication>#include <QDebug>#include <stdlib.h>#include "shoppinglist.h"void loadShoppingList(ShoppingList& slst) {    bool ok;    QString dept, item, qty, more;    QStringList dptlst, yesno;    dptlst << "Dairy" << "Meats" << "Produce"           << "Frozen Foods" << "Household"           << "Canned Goods" << "Spices";    yesno << "yes" << "no";    do {        dept = QInputDialog::            getItem(NULL, "ShoppingListApp", "Dept:",                    dptlst, 0, true, &ok);        item = QInputDialog::            getText(NULL, QString("ShoppingListApp"),                    QString("Item:"), QLineEdit::Normal,                    QString(), &ok);        qty = QInputDialog::            getText(NULL, "ShoppingListApp", "Qty:",                    QLineEdit::Normal, QString(), &ok);        slst << QString("%1 - %2 - {%3}").arg(dept)            .arg(item).arg(qty);        more = QInputDialog::            getItem(NULL, "ShoppingListApp", "Another item? ",                    yesno, 0, false, &ok);    } while (more == "yes");}int main(int argc, char* argv[]) {    QApplication app(argc, argv);    app.setQuitOnLastWindowClosed(false) ; /* this is necessary      if there is no QMainWindow and we are opening/closing       dialogs. */    ShoppingList shplst;    loadShoppingList(shplst);    qDebug() << "Send the following list to the printer:\n\n";    qDebug() << shplst.makePrintList();    return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -