#ifndef MYMAIN_H
#define MYMAIN_H
#include <QtGui/QMainWindow>
namespace Ui
{
class myMain;
}
class myMain : public QMainWindow
{
Q_OBJECT
public:
myMain(QWidget *parent = 0);
~myMain();
protected:
void paintEvent(QPaintEvent *event);
private:
QString str;
Ui::myMain *ui;
};
#endif // MYMAIN_H
#include "mymain.h"
#include "ui_mymain.h"
#include "QFile.h"
#include "QString.h"
#include "QTextStream.h"
#include "QRect.h"
#include "QFont.h"
#include "QPainter.h"
myMain::myMain(QWidget *parent)
: QMainWindow(parent), ui(new Ui::myMain)
{
ui->setupUi(this);
QFile myFile("readme.txt");
if(!myFile.open(QIODevice::ReadOnly))
return;
QTextStream stream(&myFile);
while (!stream.atEnd())
{
str = stream.readLine().toLocal8Bit();
}
}
myMain::~myMain()
{
delete ui;
}
void myMain::paintEvent(QPaintEvent *event)
{
QPainter painter(this);
QRect r = QRect(0, 0, 200, 200);
painter.setFont(QFont("Times", 14, QFont::Normal));
painter.drawRect(r);
painter.drawText(r, Qt::AlignCenter | Qt::TextWordWrap, str);
}
Ошибка collect2 ld returned 1