ntzrmtthihu777
8th August 2014, 18:52
Greetings, I'm a bit of a hobbyist programmer in a few languages, and am now finally stepping up to real application developement.
Was giving Qt a shot and I must say its very good for rapid GUI building on linux.
What I'm working on is pretty analogous to an IDE, in that you chose a 'project file' which is read in and sets up the project paths and such.
I'm having issue with a portion of it, in that I can't figure out how to pass information from the project file into a subwindow of the application;
Current code:
void MainWindow::file_open_project()
{
QString projectFile = QFileDialog::getOpenFileName(
this, tr("Open Project"),
QStandardPaths::writableLocation(QStandardPaths::D ocumentsLocation),
tr("Project files (*.proj)"));
if(!projectFile.isEmpty())
{
load_project(projectFile);
}
}
void MainWindow::load_project(QString projectFile)
{
QFileInfo project(projectFile);
QString projectPath = project.absolutePath();
QSettings *projectSettings = new QSettings(projectPath+"/Project", QSettings::IniFormat, this);
this->archiveFile->append(projectSettings->value("Archive").toString());
}
void MainWindow::archiveAction()
{
ArchiveEditor *archiveEditor = new ArchiveEditor(this, &archiveFile);
archiveEditor->setAttribute(Qt::WA_DeleteOnClose);
archiveEditor->setAttribute(Qt::WA_ShowModal);
archiveEditor->show();
}
ArchiveEditor::ArchiveEditor(QWidget *parent, QString *file)
:QWidget(parent, Qt::Window)
{
setWindowTitle(tr("Archive Editor"));
loadScriptArchive(file);
}
void ArchiveEditor::loadArchive(const QString &file)
{
QFile archiveFile = QFile(file);
if (!archiveFile.open(QFile::ReadOnly))
{
QMessageBox::critical(this,
tr("File read error"), tr("Cannot open file: ") + file);
return;
}
}
ArchiveEditor obviously doesn't do much atm, I'm just trying to figure out how to pass something from the Project.ini file into a subwindow to tell it which archive to load.
Was giving Qt a shot and I must say its very good for rapid GUI building on linux.
What I'm working on is pretty analogous to an IDE, in that you chose a 'project file' which is read in and sets up the project paths and such.
I'm having issue with a portion of it, in that I can't figure out how to pass information from the project file into a subwindow of the application;
Current code:
void MainWindow::file_open_project()
{
QString projectFile = QFileDialog::getOpenFileName(
this, tr("Open Project"),
QStandardPaths::writableLocation(QStandardPaths::D ocumentsLocation),
tr("Project files (*.proj)"));
if(!projectFile.isEmpty())
{
load_project(projectFile);
}
}
void MainWindow::load_project(QString projectFile)
{
QFileInfo project(projectFile);
QString projectPath = project.absolutePath();
QSettings *projectSettings = new QSettings(projectPath+"/Project", QSettings::IniFormat, this);
this->archiveFile->append(projectSettings->value("Archive").toString());
}
void MainWindow::archiveAction()
{
ArchiveEditor *archiveEditor = new ArchiveEditor(this, &archiveFile);
archiveEditor->setAttribute(Qt::WA_DeleteOnClose);
archiveEditor->setAttribute(Qt::WA_ShowModal);
archiveEditor->show();
}
ArchiveEditor::ArchiveEditor(QWidget *parent, QString *file)
:QWidget(parent, Qt::Window)
{
setWindowTitle(tr("Archive Editor"));
loadScriptArchive(file);
}
void ArchiveEditor::loadArchive(const QString &file)
{
QFile archiveFile = QFile(file);
if (!archiveFile.open(QFile::ReadOnly))
{
QMessageBox::critical(this,
tr("File read error"), tr("Cannot open file: ") + file);
return;
}
}
ArchiveEditor obviously doesn't do much atm, I'm just trying to figure out how to pass something from the Project.ini file into a subwindow to tell it which archive to load.