доброго времени суток, помогите пожалуйста разобраться!...
не могу понять как открыть файл .csv и как заполнить им tableWidget желательно используя split
я создал форму при помощи Qt Designer в итоге получилось ui_form.h следующие
/********************************************************************************
** Form generated from reading UI file 'form.ui'
**
** Created: Mon 24. May 21:39:48 2010
** by: Qt User Interface Compiler version 4.6.0
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_FORM_H
#define UI_FORM_H
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QGridLayout>
#include <QtGui/QHBoxLayout>
#include <QtGui/QHeaderView>
#include <QtGui/QMainWindow>
#include <QtGui/QMenu>
#include <QtGui/QMenuBar>
#include <QtGui/QStatusBar>
#include <QtGui/QTableWidget>
#include <QtGui/QWidget>
QT_BEGIN_NAMESPACE
class Ui_Form
{
public:
QAction *openF;
QAction *save;
QAction *close;
QAction *cope;
QAction *past;
QAction *cut;
QWidget *centralwidget;
QGridLayout *gridLayout;
QHBoxLayout *horizontalLayout;
QTableWidget *tableWidget_2;
QTableWidget *tableWidget;
QMenuBar *menubar;
QMenu *menu;
QMenu *menu_2;
QMenu *menu_3;
QStatusBar *statusbar;
void setupUi(QMainWindow *Form)
{
if (Form->objectName().isEmpty())
Form->setObjectName(QString::fromUtf8("Form"));
Form->resize(800, 600);
openF = new QAction(Form);
openF->setObjectName(QString::fromUtf8("openF"));
save = new QAction(Form);
save->setObjectName(QString::fromUtf8("save"));
close = new QAction(Form);
close->setObjectName(QString::fromUtf8("close"));
cope = new QAction(Form);
cope->setObjectName(QString::fromUtf8("cope"));
past = new QAction(Form);
past->setObjectName(QString::fromUtf8("past"));
cut = new QAction(Form);
cut->setObjectName(QString::fromUtf8("cut"));
centralwidget = new QWidget(Form);
centralwidget->setObjectName(QString::fromUtf8("centralwidget"));
gridLayout = new QGridLayout(centralwidget);
gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
horizontalLayout = new QHBoxLayout();
horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
tableWidget_2 = new QTableWidget(centralwidget);
tableWidget_2->setObjectName(QString::fromUtf8("tableWidget_2"));
horizontalLayout->addWidget(tableWidget_2);
tableWidget = new QTableWidget(centralwidget);
tableWidget->setObjectName(QString::fromUtf8("tableWidget"));
tableWidget->setShowGrid(true);
horizontalLayout->addWidget(tableWidget);
gridLayout->addLayout(horizontalLayout, 0, 0, 1, 1);
Form->setCentralWidget(centralwidget);
menubar = new QMenuBar(Form);
menubar->setObjectName(QString::fromUtf8("menubar"));
menubar->setGeometry(QRect(0, 0, 800, 21));
menu = new QMenu(menubar);
menu->setObjectName(QString::fromUtf8("menu"));
menu_2 = new QMenu(menubar);
menu_2->setObjectName(QString::fromUtf8("menu_2"));
menu_3 = new QMenu(menubar);
menu_3->setObjectName(QString::fromUtf8("menu_3"));
Form->setMenuBar(menubar);
statusbar = new QStatusBar(Form);
statusbar->setObjectName(QString::fromUtf8("statusbar"));
Form->setStatusBar(statusbar);
QWidget::setTabOrder(tableWidget_2, tableWidget);
menubar->addAction(menu->menuAction());
menubar->addAction(menu_2->menuAction());
menubar->addAction(menu_3->menuAction());
menu->addAction(openF);
menu->addAction(save);
menu->addSeparator();
menu->addAction(close);
menu_2->addAction(cope);
menu_2->addAction(past);
menu_2->addAction(cut);
retranslateUi(Form);
QObject::connect(close, SIGNAL(activated()), Form, SLOT(close()));
QMetaObject::connectSlotsByName(Form);
} // setupUi
void retranslateUi(QMainWindow *Form)
{
Form->setWindowTitle(QApplication::translate("Form", "MainWindow", 0, QApplication::UnicodeUTF8));
openF->setText(QApplication::translate("Form", "&\320\276\321\202\320\272\321\200\321\213\321\202\321\214", 0, QApplication::UnicodeUTF8));
save->setText(QApplication::translate("Form", "&\321\201\320\276\321\205\321\200\320\276\320\275\320\270\321\202\321\214", 0, QApplication::UnicodeUTF8));
close->setText(QApplication::translate("Form", "\320\262\321\213&\321\205\320\276\320\264", 0, QApplication::UnicodeUTF8));
cope->setText(QApplication::translate("Form", "\320\272\320\276\320\277\320\270\321\200\320\276\320\262\320\260\321\202\321\214", 0, QApplication::UnicodeUTF8));
past->setText(QApplication::translate("Form", "\320\262\321\201\321\202\320\260\320\262\320\270\321\202\321\214", 0, QApplication::UnicodeUTF8));
cut->setText(QApplication::translate("Form", "\320\262\321\213\321\200\320\265\320\267\320\260\321\202\321\214", 0, QApplication::UnicodeUTF8));
menu->setTitle(QApplication::translate("Form", "&\320\244\320\260\320\271\320\273", 0, QApplication::UnicodeUTF8));
menu_2->setTitle(QApplication::translate("Form", "&\320\237\321\200\320\260\320\262\320\272\320\260", 0, QApplication::UnicodeUTF8));
menu_3->setTitle(QApplication::translate("Form", "\320\241\320\277\321\200\320\260\320\262\320\272\320\260", 0, QApplication::UnicodeUTF8));
} // retranslateUi
};
namespace Ui {
class Form: public Ui_Form {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_FORM_H
далее создаю еще один заголовочный файл form.h
#ifndef FORM_H
#define FORM_H
#include <QApplication>
#include <QMainWindow>
#include <QDialog>
#include "ui_form.h"
class Form : public QDialog, public Ui::Form
{
Q_OBJECT
public:
Form();
private slots:
void openFail(QString fileName);};
#endif // FORM_H
и файл form.cpp
#include <QApplication>
#include <QMainWindow>
#include <QtGui>
#include "ui_form.h"
#include "form.h"
Form::Form()
{
connect(Ui_Form::openF,SIGNAL(triggered()),this,SLOT(openFail(QString)));
}
void Form::openFail(QString fileName)
{
fileName = QFileDialog::getOpenFileName(this,
tr("Open Spreadsheet"), ".",
tr("Spreadsheet files (*.scv)"));
if(fileName.isEmpty()) ;
QFile *file = new QFile(fileName, this);
if(!file->open(QIODevice::ReadOnly)) {
QMessageBox::warning(new QWidget,tr("Warning in entery file"),
tr("Cannont read file %1:\n%2.")
.arg(file->fileName()).arg(file->errorString()));
}
while(!file->atEnd())
{
}
}
ну и main.cpp
#include <QApplication>
#include <QMainWindow>
#include "ui_form.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
Ui::Form ui;
QMainWindow *dialog = new QMainWindow;
ui.setupUi(dialog);
dialog->show();
return app.exec();
}
вот все что пока есть,... я конечно понимаю что довольно глупый вопрос но может ли кто помочь?....