shoppinglist-test.cpp.svn-base

来自「QT方面的开发」· SVN-BASE 代码 · 共 55 行

SVN-BASE
55
字号
#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 + =
减小字号Ctrl + -
显示快捷键?