Dun'kalis
01-25-2003, 11:25 PM
I'm learning Qt, and its really well-designed, but I really can't get this to work.
I want to open a file and load that in to the proper text widget.
The text widget is derived from QTextEdit, and is called TextEditor (very original). The widget class declaration is in editor.h, and the code that creates an instance of that class is in editor.cpp.
void EditorMenu::open()
{
QString fileName = QFileDialog::getOpenFileName(
"home",
"C/C++ Files (*.c, *.C, *.cpp, *.cxx, *.h)",
this,
"open file dialog",
"Open File...");
QFile fileData(fileName);
fileData.open;
editor->setText(fileData); // hmm...
}
EditorMenu is a QMenuBar instance. I want to load the file fileName to the TextEditor control. I'm guessing this is close to the right way, but when it compiles, it spits back an error.
In my editor.cpp, I have the following in it (there is more, but its not important)
QTextEdit *editor = new QTextEdit(this);
I also tried it with Editor->setText(fileData); but that didn't work, either.
Whats wrong? I know that this has got to be hard to solve without all the code, but there is 186 lines, and I doubt anyone wants to sift through all that to solve a problem with one part of the code.
Another quicker question:
I want to have a menu entry for exiting, and I believe I should be able to do the following:
QObject::connect(&EditorMenu::closeApp, SIGNAL(activated()), qApp, SLOT(quit()));
Which pops out this error message on compile:
menus.h: In member function `void EditorMenu::closeApp()':
menus.h:101: no matching function for call to `QObject::connect(void
(EditorMenu::*)(), const char[13], QApplication*&, const char[8])'
/opt/qt/include/qobject.h:116: candidates are: static bool
QObject::connect(const QObject*, const char*, const QObject*, const char*)
/opt/qt/include/qobject.h:227: bool QObject::connect(const
QObject*, const char*, const char*) const
Any ideas?
I want to open a file and load that in to the proper text widget.
The text widget is derived from QTextEdit, and is called TextEditor (very original). The widget class declaration is in editor.h, and the code that creates an instance of that class is in editor.cpp.
void EditorMenu::open()
{
QString fileName = QFileDialog::getOpenFileName(
"home",
"C/C++ Files (*.c, *.C, *.cpp, *.cxx, *.h)",
this,
"open file dialog",
"Open File...");
QFile fileData(fileName);
fileData.open;
editor->setText(fileData); // hmm...
}
EditorMenu is a QMenuBar instance. I want to load the file fileName to the TextEditor control. I'm guessing this is close to the right way, but when it compiles, it spits back an error.
In my editor.cpp, I have the following in it (there is more, but its not important)
QTextEdit *editor = new QTextEdit(this);
I also tried it with Editor->setText(fileData); but that didn't work, either.
Whats wrong? I know that this has got to be hard to solve without all the code, but there is 186 lines, and I doubt anyone wants to sift through all that to solve a problem with one part of the code.
Another quicker question:
I want to have a menu entry for exiting, and I believe I should be able to do the following:
QObject::connect(&EditorMenu::closeApp, SIGNAL(activated()), qApp, SLOT(quit()));
Which pops out this error message on compile:
menus.h: In member function `void EditorMenu::closeApp()':
menus.h:101: no matching function for call to `QObject::connect(void
(EditorMenu::*)(), const char[13], QApplication*&, const char[8])'
/opt/qt/include/qobject.h:116: candidates are: static bool
QObject::connect(const QObject*, const char*, const QObject*, const char*)
/opt/qt/include/qobject.h:227: bool QObject::connect(const
QObject*, const char*, const char*) const
Any ideas?