int i = Calendar::i;
class Calendar: public QMainWindow{ Q_OBJECTpublic: Calendar(); int i; QList<QString> tableweek,tableday,tablenum,tablename;public slots: void raspisanie(QDate); void setCurrDay(QDate);private: void insertDate(); bool ok; QDate selectedDate,firstDate; QTextBrowser *editor; int cur_week; QCalendarWidget * monthcalendar;};
#include "calendar.h"#include <QtGui>#include <QFile>#include <QTextCodec>Calendar::Calendar(){ // тут был кусок кода QFile file("db.ini"); if (!file.open(QIODevice::ReadWrite | QIODevice::Text)) editor->insertPlainText(tr("Файл не существует")); QTextStream filein(&file); QString line = filein.readLine(); QList<QString> list2 = line.split(" ", QString::SkipEmptyParts); int mf,yf,df; df = list2[0].toInt(&ok,10); mf = list2[1].toInt(&ok,10); yf = list2[2].toInt(&ok,10); firstDate = QDate(yf,mf,df); i=0; while (!filein.atEnd()) { line = filein.readLine(); list2 = line.split(" ", QString::SkipEmptyParts); tableweek.append(list2[0]); tableday.append(list2[1]); tablenum.append(list2[2]); tablename.append(list2[3]); i++; } file.close();
class Table: public QMainWindow{ Q_OBJECTpublic: Table();public slots:private: QTreeWidget* table;};
#include <QtGui>#include <QFile>#include "table.h"#include "calendar.h"Table::Table(){ QTextCodec::setCodecForTr(QTextCodec::codecForName("CP1251")); table = new QTreeWidget(); table->setColumnCount(4); table->setHeaderLabel(tr("Неделя")); int i = Calendar::i; QVBoxLayout * layout = new QVBoxLayout; layout->addWidget(table); QWidget *widget = new QWidget; setCentralWidget(widget); widget->setLayout(layout);}
if (!file.open(QIODevice::ReadWrite | QIODevice::Text)) editor->insertPlainText(tr("Файл не существует"));QTextStream filein(&file);
if (!file.open(QIODevice::ReadOnly)) { editor->insertPlainText(tr("Файл не существует")); return;}QTextStream filein(&file);
class Calendar;class Table : public QMainWindow{Calendar * cal;Table(){ cal = new Calendar(); int i = cal->i;}}