Re: static member function
Quote:
Something even confused me more. The ui header indicates "WARNING! All changes made in this file will be lost when recompiling ui file!"
You cannot edit the ui_.h file as they are generated based on the ui file.
You shoul edit the looper.h and looper.cpp files. There should be a member pointer in the looper .h someething like 'm_ui' that would gave you access to the textedit, but I dont see it in your code.
4 Attachment(s)
Re: static member function
I tried to absorb the idea of having a static member function which would handle my textEdit so that I could call the function even without instance of the class I made, basicLoop.
I recompiled and got this error message:
C: .../looper.cpp:18: undefined reference to 'basicLoop::textEdit'
Code:
class basicLoop
: public QWidget,
private Ui
::looperDLG{
Q_OBJECT
public:
static void textEditAppend (int&);
public slots:
void startLoop();
void stopLoop();
private:
};
I'm not sure if I implemented the correct static data in my looper.h. I think this is the part that gives me the error. So how can I make Ui_looperDLG::textEdit be my static data?
I'm somehow getting lost with the idea of the UI header file. If I'm not on the right track, I hope you give give me some light. Thanks.
Re: static member function
you have to do it like this..
Code:
//header
class basicLoop
: public QWidget,
private Ui
::looperDLG{
private:
static QTextEdit* te;
//name it different than ui header public:
}
//cpp
#include <QtGui>
#include "looper.h"
bool stop;
void mainLoop();
QTextEdit* basicLoop
::te=0;
//MUST do it here globaly...
basicLoop
::basicLoop(QWidget *parent
) {
setupUi(this); // this sets up GUI
te= textEdit//This textEdit is inherited from ui header
}
{
return te;
}
now you can call the basicloop::gettextEdit() in your mainloop()...
this is not the best solution.. coz this assumes that you are using only single instance of basicloop... becoz everytime a new object of basicloop is created the textedit will change.. if you only use one instance of basicloop.. make it a singleton class.
Re: static member function
Thanks finally got it working.:D