Answer the question
In order to leave comments, you need to log in
Framework Qt 4.7. Problem when generating virtual table pointers?
Let's start in order. There is a description of a certain class responsible for the visual design of the program.
#include <QtGui>
class Windows : public QObject
{
protected:
friend class MyClass;
QPushButton *but1;
QPushButton *but2;
public:
Windows(QApplication *App);
QPushButton *RUN;
}
#include <windows.h>
#include <QFile>
#include <cstdlib>
class MyClass : public QObject
{
Q_OBJECT
private:
int number_of_lines;
public:
MyClass (QApplication*App);
Windows *win; // Объект, отвечающий за визуализацию
public slots:
void myFunc();
}
MyClass:: MyClass (QApplication *App) // Конструктор
{
win = new Windows (App);
}
void MyClass::myFunc()
{ }
#include "myclass.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
MyClass *c1 = new MyClass (&app);
QObject::connect(c1->win->RUN, SIGNAL(clicked()),
c1, SLOT(myFunc()));
return app.exec();
}
#include "myclass.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
MyClass *c1 = new MyClass (&app);
c1->myFunc();
}
Answer the question
In order to leave comments, you need to log in
>MyClass:: MyClass(QApplication *App) // Constructor
Mother my woman! qapp is a singleton! Friend classes in this particular case are not needed at all and are rather harmful. And I also advise you to smoke on the topic of moc, in main.cpp if you really want to declare a class dependent on the QObject file, then you need to write #include "moc_main.cxx" at the end or same #include "main.moc"
And in general, all the code is not written in the spirit of Qt, but in some strange way. It's better to read some cool examples for starters and in the coding conventions docs!
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question