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

📄 qprintdialog_qws.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 2 页
字号:
    // file name    fileName = q->findChild<QLineEdit *>("fileName");    QObject::connect(fileName, SIGNAL(textChanged(QString)),            q, SLOT(_q_fileNameEditChanged(QString)));    outputToFile = false;}void QPrintDialogPrivate::setupPrinterSettings(){    Q_Q(QPrintDialog);    // color mode    colorMode = new QButtonGroup(q);    QObject::connect(colorMode, SIGNAL(buttonClicked(QAbstractButton *)),        q, SLOT(_q_colorModeSelected(QAbstractButton *)));    printColor = q->findChild<QRadioButton *>("printColor");    colorMode->addButton(printColor);    printGray = q->findChild<QRadioButton *>("printGray");    colorMode->addButton(printGray);}void isc(QPrintDialogPrivate *ptr, const QString & text, QPrinter::PageSize ps){    if (ptr && !text.isEmpty() && ps < QPrinter::NPageSize) {        ptr->sizeCombo->addItem(text);        int index = ptr->sizeCombo->count()-1;        if (index >= 0 && index < QPrinter::NPageSize)            ptr->indexToPageSize[index] = ps;    }}void QPrintDialogPrivate::setupPaper(){    Q_Q(QPrintDialog);    pageSize = QPrinter::A4;    // paper orientation    orientationCombo = q->findChild<QComboBox *>("orientationCombo");    orientation = QPrinter::Portrait;    QObject::connect(orientationCombo, SIGNAL(activated(int)),            q, SLOT(_q_orientSelected(int)));    // paper size    sizeCombo = q->findChild<QComboBox *>("sizeCombo");    int n;    for(n=0; n<QPrinter::NPageSize; n++)        indexToPageSize[n] = QPrinter::A4;    isc(this, QPrintDialog::tr("A0 (841 x 1189 mm)"), QPrinter::A0);    isc(this, QPrintDialog::tr("A1 (594 x 841 mm)"), QPrinter::A1);    isc(this, QPrintDialog::tr("A2 (420 x 594 mm)"), QPrinter::A2);    isc(this, QPrintDialog::tr("A3 (297 x 420 mm)"), QPrinter::A3);    isc(this, QPrintDialog::tr("A4 (210 x 297 mm, 8.26 x 11.7 inches)"), QPrinter::A4);    isc(this, QPrintDialog::tr("A5 (148 x 210 mm)"), QPrinter::A5);    isc(this, QPrintDialog::tr("A6 (105 x 148 mm)"), QPrinter::A6);    isc(this, QPrintDialog::tr("A7 (74 x 105 mm)"), QPrinter::A7);    isc(this, QPrintDialog::tr("A8 (52 x 74 mm)"), QPrinter::A8);    isc(this, QPrintDialog::tr("A9 (37 x 52 mm)"), QPrinter::A9);    isc(this, QPrintDialog::tr("B0 (1000 x 1414 mm)"), QPrinter::B0);    isc(this, QPrintDialog::tr("B1 (707 x 1000 mm)"), QPrinter::B1);    isc(this, QPrintDialog::tr("B2 (500 x 707 mm)"), QPrinter::B2);    isc(this, QPrintDialog::tr("B3 (353 x 500 mm)"), QPrinter::B3);    isc(this, QPrintDialog::tr("B4 (250 x 353 mm)"), QPrinter::B4);    isc(this, QPrintDialog::tr("B5 (176 x 250 mm, 6.93 x 9.84 inches)"), QPrinter::B5);    isc(this, QPrintDialog::tr("B6 (125 x 176 mm)"), QPrinter::B6);    isc(this, QPrintDialog::tr("B7 (88 x 125 mm)"), QPrinter::B7);    isc(this, QPrintDialog::tr("B8 (62 x 88 mm)"), QPrinter::B8);    isc(this, QPrintDialog::tr("B9 (44 x 62 mm)"), QPrinter::B9);    isc(this, QPrintDialog::tr("B10 (31 x 44 mm)"), QPrinter::B10);    isc(this, QPrintDialog::tr("C5E (163 x 229 mm)"), QPrinter::C5E);    isc(this, QPrintDialog::tr("DLE (110 x 220 mm)"), QPrinter::DLE);    isc(this, QPrintDialog::tr("Executive (7.5 x 10 inches, 191 x 254 mm)"), QPrinter::Executive);    isc(this, QPrintDialog::tr("Folio (210 x 330 mm)"), QPrinter::Folio);    isc(this, QPrintDialog::tr("Ledger (432 x 279 mm)"), QPrinter::Ledger);    isc(this, QPrintDialog::tr("Legal (8.5 x 14 inches, 216 x 356 mm)"), QPrinter::Legal);    isc(this, QPrintDialog::tr("Letter (8.5 x 11 inches, 216 x 279 mm)"), QPrinter::Letter);    isc(this, QPrintDialog::tr("Tabloid (279 x 432 mm)"), QPrinter::Tabloid);    isc(this, QPrintDialog::tr("US Common #10 Envelope (105 x 241 mm)"), QPrinter::Comm10E);    QObject::connect(sizeCombo, SIGNAL(activated(int)),             q, SLOT(_q_paperSizeSelected(int)));}void QPrintDialogPrivate::setupOptions(){    Q_Q(QPrintDialog);    // no. of copies    copies = q->findChild<QSpinBox *>("copies");    QObject::connect(copies, SIGNAL(valueChanged(int)),            q, SLOT(_q_setNumCopies(int)));    // print range    rangeCombo = q->findChild<QComboBox *>("rangeCombo");    rangeCombo->addItem(QPrintDialog::tr("Print all"), QPrintDialog::AllPages);    rangeCombo->addItem(QPrintDialog::tr("Print selection"), QPrintDialog::Selection);    rangeCombo->addItem(QPrintDialog::tr("Print range"), QPrintDialog::PageRange);    QObject::connect(rangeCombo, SIGNAL(activated(int)),            q, SLOT(_q_printRangeSelected(int)));    // page range    firstPage = q->findChild<QSpinBox *>("firstPage");    firstPage->setRange(1, 9999);    firstPage->setValue(1);    QObject::connect(firstPage, SIGNAL(valueChanged(int)),            q, SLOT(_q_setFirstPage(int)));    lastPage = q->findChild<QSpinBox *>("lastPage");    lastPage->setRange(1, 9999);    lastPage->setValue(1);    QObject::connect(lastPage, SIGNAL(valueChanged(int)),            q, SLOT(_q_setLastPage(int)));    // print order    pageOrderCombo = q->findChild<QComboBox *>("pageOrderCombo");    QObject::connect(pageOrderCombo, SIGNAL(activated(int)),            q, SLOT(_q_pageOrderSelected(int)));}bool QPrintDialog::eventFilter(QObject *o, QEvent *e){    Q_UNUSED(o);    Q_D(QPrintDialog);    switch (e->type()){    case QEvent::KeyPress:        switch (static_cast<QKeyEvent*>(e)->key()) {        case Qt::Key_Back:            d->_q_okClicked();            return true;        }        break;    default:        break;    }    return false;}QPrintDialog::QPrintDialog(QPrinter *printer, QWidget *parent)    : QAbstractPrintDialog(*(new QPrintDialogPrivate), printer, parent){    d_func()->init();}QPrintDialog::~QPrintDialog(){}void QPrintDialogPrivate::setPrinter(QPrinter *p, bool pickUpSettings){    Q_Q(QPrintDialog);    printer = p;    if (p && pickUpSettings) {        // top to bottom in the old dialog.        // printer or file        outputToFile = !p->outputFileName().isEmpty() && q->isOptionEnabled(QPrintDialog::PrintToFile);        if (outputToFile)            printToFileButton->setChecked(true);        else            printToPrinterButton->setChecked(true);        fileName->setEnabled(outputToFile);        // file name        if (q->isOptionEnabled(QPrintDialog::PrintToFile)) {            fileName->setText(p->outputFileName());            fileName->setModified(!fileName->text().isEmpty());        } else {            printToFileButton->setEnabled(false);        }        // orientation        orientationCombo->setCurrentIndex((int)p->orientation());        _q_orientSelected(p->orientation());        // page size        int n = 0;        while (n < QPrinter::NPageSize &&                indexToPageSize[n] != p->pageSize())            n++;        sizeCombo->setCurrentIndex(n);        _q_paperSizeSelected(n);        // page order        pageOrder2 = p->pageOrder();        pageOrderCombo->setCurrentIndex((int)pageOrder2);        // color mode        colorMode2 = p->colorMode();        if (colorMode2 == QPrinter::Color)            printColor->setChecked(true);        else            printGray->setChecked(true);        // number of copies        copies->setValue(p->numCopies());        _q_setNumCopies(p->numCopies());    }    if (p) {        if (!q->isOptionEnabled(QPrintDialog::PrintSelection)                && rangeCombo->findData(QPrintDialog::Selection) > 0)            rangeCombo->removeItem(rangeCombo->findData(QPrintDialog::Selection));        if (!q->isOptionEnabled(QPrintDialog::PrintPageRange)                && rangeCombo->findData(QPrintDialog::PageRange) > 0)            rangeCombo->removeItem(rangeCombo->findData(QPrintDialog::PageRange));        switch (q->printRange()) {        case QPrintDialog::AllPages:            rangeCombo->setCurrentIndex((int)(QPrintDialog::AllPages));            break;        case QPrintDialog::Selection:            rangeCombo->setCurrentIndex((int)(QPrintDialog::Selection));            break;        case QPrintDialog::PageRange:            rangeCombo->setCurrentIndex((int)(QPrintDialog::PageRange));            break;        }    }    if (p && q->maxPage()) {        int from = q->minPage();        int to = q->maxPage();        if (q->printRange() == QPrintDialog::PageRange) {            from = q->fromPage();            to = q->toPage();        }        firstPage->setRange(q->minPage(), to);        lastPage->setRange(from, q->maxPage());        firstPage->setValue(from);        lastPage->setValue(to);    }}int QPrintDialog::exec(){    Q_D(QPrintDialog);    d->setPrinter(d->printer, true);    return QDialog::exec();}void QPrintDialogPrivate::init(){    Q_Q(QPrintDialog);    numCopies = 1;    if (_qt_print_dialog_creator)        (*_qt_print_dialog_creator)(q);    setupDestination();    setupPrinterSettings();    setupPaper();    setupOptions();    setPrinter(printer, true);    q->installEventFilter(q);}#include "moc_qprintdialog.cpp"#endif // QT_NO_PRINTDIALOG

⌨️ 快捷键说明

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