#include <QApplication>
#include "MainWindow.h"
int main(int argc, char *argv[])
{
MainWindow *lc_dialog = new MainWindow;
lc_dialog->show();
return a.exec();
}
#include <QApplication>
#include "MainWindow.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow *lc_dialog = new MainWindow;
lc_dialog->show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
{
Q_OBJECT
public:
MainWindow();
public slots:
void print();
};
class MainWindow: public QMainWindow
{
Q_OBJECT
public:
MainWindow();
public slots:
void print();
};
To copy to clipboard, switch view to plain text mode
#include "MainWindow.h"
#include <iostream>
#include <QPushButton>
#include <QTextEdit>
#include <QPrinter>
using namespace std;
MainWindow::MainWindow()
{
cout << "MainWindow - start" << endl;
this->setGeometry(400,400,500,100);
button1->setText("ok");
button2->setText("Concel");
button1->setGeometry(15, this->size().height() - 30, this->size().width()/2 -20, 30);
button2->setGeometry(this->size().width()/2 + 5, this->size().height() - 30, this->size().width()/2 -20, 30);
textEdit->setText("Petit texte brut de test");
textEdit->setGeometry(0, 0, this->size().width(), 50);
button1->show();
button2->show();
connect(button1, SIGNAL(clicked()), this, SLOT(print()) );
connect(button2, SIGNAL(clicked()), this, SLOT(print()) );
this->show();
cout << "MainWindow - end" << endl;
}
void MainWindow::print()
{
cout << "print - start" << endl;
prn.setOutputFileName("/Path/to/my/pdf/out.pdf");
cout << "print - end" << endl;
}
#include "MainWindow.h"
#include <iostream>
#include <QPushButton>
#include <QTextEdit>
#include <QPrinter>
using namespace std;
MainWindow::MainWindow()
:QMainWindow()
{
cout << "MainWindow - start" << endl;
this->setGeometry(400,400,500,100);
QPushButton *button1 = new QPushButton(this);
QPushButton *button2 = new QPushButton(this);
button1->setText("ok");
button2->setText("Concel");
button1->setGeometry(15, this->size().height() - 30, this->size().width()/2 -20, 30);
button2->setGeometry(this->size().width()/2 + 5, this->size().height() - 30, this->size().width()/2 -20, 30);
QTextEdit *textEdit = new QTextEdit(this);
textEdit->setText("Petit texte brut de test");
textEdit->setGeometry(0, 0, this->size().width(), 50);
button1->show();
button2->show();
connect(button1, SIGNAL(clicked()), this, SLOT(print()) );
connect(button2, SIGNAL(clicked()), this, SLOT(print()) );
this->show();
cout << "MainWindow - end" << endl;
}
void MainWindow::print()
{
cout << "print - start" << endl;
QPrinter prn;
prn.setOutputFileName("/Path/to/my/pdf/out.pdf");
render(&prn, QPoint(), QRegion(), QWidget::DrawChildren | QWidget::DrawWindowBackground);
cout << "print - end" << endl;
}
To copy to clipboard, switch view to plain text mode
[Session started at 2008-02-23 23:55:39 +0100.]
MainWindow - start
MainWindow - end
print - start
print - end
[Session started at 2008-02-23 23:55:39 +0100.]
MainWindow - start
MainWindow - end
print - start
print - end
To copy to clipboard, switch view to plain text mode
Bookmarks