I am trying to make a program that pulls text from a text file indicated by the user (typing the file path in a lineEdit) and displays it on a text edit widget. Here's what I have so far:
#include <QApplication>
#include <QtGui>
#include <QtCore>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QWidget *window = new QWidget;
window->setWindowTitle("Text Reader");
QGridLayout *layout = new QGridLayout;
QTextEdit *textbox = new QTextEdit();
QLineEdit *enterFile = new QLineEdit();
QPushButton *goButton = new QPushButton("Ok");
QPushButton *quitButton = new QPushButton("Quit");
layout->addWidget(textbox, 0,0,1,1);
layout->addWidget(enterFile, 1,0,1,1);
layout->addWidget(goButton, 2,0,1,1);
layout->addWidget(quitButton, 3,0,1,1);
window->setLayout(layout);
QObject::connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit()));
//
//STUFF TO BE ADDED
//
window->show();
return app.exec(); //Starts main event loop
}
This is just the shell of things, and I'm learning as I add things in. I'll add in all the stuff for opening the file and storing it's contents into a QString later, but how do I take the text from 'enterFile' (a QLineEdit), and store that into a QString? I'll end up using that string to open up a file and load its text onto the textEdit widget. I've tried using a SIGNAL/SLOT mechanism thing, but it doesn't seem to do anything.
Also, I'm totally new to qt and object oriented programming. The only experience I have is working with console applications in VC++ (though I know the basics there well enough)
Bookmarks