[SOLVED] textEdit not letting me access any of its functions
-
Yes, I did clean the project and run qmake. Sorry, I forgot to mention that in my last post.
-
Just to clarify, nothing in my textEdit ("programTextEdit") works. I get the same error when I try accessing anything in the ui.
-
I played around. If I put the following lines:
@ ui->programTextEdit->setPlainText(line);
ui->runButton->setEnabled(true);
ui->pauseButton->setEnabled(true);@in the constructor, I get no build error. The errors only come up if I throw it in a separate function within my source file. Why is that?
-
Is your separate function a member of BasicGui ?
-
Yup. See below (displayProgram):
@#ifndef BASICGUI_H
#define BASICGUI_H#include <QMainWindow>
#include <QtGui>
#include <QtCore>namespace Ui {
class BasicGui;
}class BasicGui : public QMainWindow
{
Q_OBJECTpublic:
explicit BasicGui(QWidget *parent = 0);
~BasicGui();
static void displayProgram(QString);private slots:
void on_selectProgramButton_clicked();
void on_loadProgramButton_clicked();private:
Ui::BasicGui *ui;};
#endif // BASICGUI_H@
-
So you are trying to modify a private class member from a static function ?
That's not allowed
-
[quote author="SGaist" date="1368717950"]So you are trying to modify a private class member from a static function ?
That's not allowed[/quote]
OK, I made the function non-static, but am now getting a function saying "error: C2352: 'BasicGui::displayProgram' : illegal call of non-static member function" when trying to call the function from another class/file with the following code:
@ BasicGui::displayProgram(aPath);@
-
@
ui->displayProgram(aPath);
@ -
[quote author="raven-worx" date="1368719638"]@
ui->displayProgram(aPath);
@[/quote]displayProgram() is from another class (Ui::BasicGui) so when I do that it says that displayProgram is not a member of the class that I am making the call in (which in this case is called Ui::SelectFile).
-
I got it to work. I didn't make an object of BasicGui in my SelectFile class. I did the following for it to work:
@public:
explicit SelectFile(QWidget *parent = 0);
~SelectFile();
BasicGui *basicgui;
@Then I made a call to basicgui->displayProgram()
-
Your code looks like it's getting messy. You are starting to have pointers to objects not directly related to those you are using.
May I suggest reading some of the examples from the Qt documentation ?
Typically updating your line edit content from another widget should be done using signals and slots (Unless I misunderstood your code). Or if SelectFile is a dialog to select a file (like the name suggests) why not use QFileDialog from BasicGui and directly update the line edit ?
-
OK. I will do some HW. Thanks!