我是qt的新手。我想制作一个简单的项目,它将从打印机打印文本。 每当我使用在Qt中打印至纸张
QPrinter printer;
QPrintDialog *dialog = new QPrintDialog(&printer, this);
dialog->setWindowTitle(tr("Print Document"));
if (editor->textCursor().hasSelection())
dialog->addEnabledOption(QAbstractPrintDialog::PrintSelection);
if (dialog->exec() != QDialog::Accepted)
return;
或本
QPrinter printer(QPrinter::HighResolution);
printer.setOutputFileName("print.ps");
QPainter painter;
painter.begin(&printer);
for (int page = 0; page < numberOfPages; ++page) {
// Use the painter to draw on the page.
if (page != lastPage)
printer.newPage();
}
painter.end();
我只是复制粘贴此我mainwindow.cpp(并试图将其粘贴到main.cpp中太),以检查是否正常工作。它不是。 我越来越喜欢这些
mainwindow.obj:-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual _thiscall QPrinter::~QPrinter(void)" ([email protected]@[email protected]) referenced in function "private: void __thiscall MainWindow::on_pushButton_clicked(void)" ([email protected]@@AAEXXZ).
有人能告诉我一步一步,如何打印到打印机的几个误区? 我也在网上查了很多,但没有得到任何相关的教程,甚至没有得到任何例子。 所以,请把它写在这里,而不是将我链接到另一个页面。
听起来像你没有正确配置你的项目(Visual C++,我假设?)。您需要在项目设置中添加Qt库,以便链接程序能够找到它们。 – us2012
您可能错过了#include声明? –
每当我想包括,它是建议 我正在使用qtCreator和msvc2010 这里是一个快照: http://i39.tinypic.com/2h82r74.jpg –