Ok, here goes. This is the simplified version which represents the problem.
main.cpp
#include <QApplication>
#include "a.h"
int main(int argc, char *argv[]){
A a;
a.show();
return app.exec();
}
#include <QApplication>
#include "a.h"
int main(int argc, char *argv[]){
QApplication app(argc, argv);
A a;
a.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
a.h
#ifndef A_H
#define A_H
#include <QWidget>
#include <QPushButton>
#include <QVBoxLayout>
#include <QApplication>
#include <qDebug>
{
Q_OBJECT
public:
A();
void changeButtonText();
public slots:
void buttonPressed();
private:
};
#endif
#ifndef A_H
#define A_H
#include <QWidget>
#include <QPushButton>
#include <QVBoxLayout>
#include <QApplication>
#include <qDebug>
class A : public QWidget
{
Q_OBJECT
public:
A();
void changeButtonText();
public slots:
void buttonPressed();
private:
QPushButton *button;
QVBoxLayout *layout;
};
#endif
To copy to clipboard, switch view to plain text mode
a.cpp
#include "a.h"
#include "b.h"
A::A()
{
setLayout(layout);
connect(button,SIGNAL(clicked()),this,SLOT(buttonPressed()));
layout->addWidget(button);
}
void A::buttonPressed()
{
B *ObjectB;
ObjectB = new B;
}
void A::changeButtonText()
{
button->setText(tr("here"));
qDebug(button->text().toLocal8Bit());
}
#include "a.h"
#include "b.h"
A::A()
{
layout = new QVBoxLayout();
setLayout(layout);
button = new QPushButton(tr("try"));
connect(button,SIGNAL(clicked()),this,SLOT(buttonPressed()));
layout->addWidget(button);
}
void A::buttonPressed()
{
B *ObjectB;
ObjectB = new B;
}
void A::changeButtonText()
{
button->setText(tr("here"));
QApplication::processEvents();
qDebug(button->text().toLocal8Bit());
}
To copy to clipboard, switch view to plain text mode
b.h
#ifndef B_H
#define B_H
#include "a.h"
class B : public A
{
Q_OBJECT
public:
B();
};
#endif
#ifndef B_H
#define B_H
#include "a.h"
class B : public A
{
Q_OBJECT
public:
B();
};
#endif
To copy to clipboard, switch view to plain text mode
b.cpp
#include "b.h"
B::B()
{
changeButtonText();
}
#include "b.h"
B::B()
{
changeButtonText();
}
To copy to clipboard, switch view to plain text mode
Test.pro
TEMPLATE = app
CONFIG += qt warn_on embed_manifest_exe console
QT += network
TARGET = Test
SOURCES = main.cpp a.cpp b.cpp
HEADERS = a.h b.h
LIBS +=
# Treat warnings as errors
win32:QMAKE_CXXFLAGS += /WX
CONFIG(debug, debug|release){
# Debug build options
# Enable a read-only console window (i.e. for printf etc.)
# CONFIG += console
}
else{
# Release build options
# Enable a read-only console window (i.e. for printf etc.)
# CONFIG += console
}
TEMPLATE = app
CONFIG += qt warn_on embed_manifest_exe console
QT += network
TARGET = Test
SOURCES = main.cpp a.cpp b.cpp
HEADERS = a.h b.h
LIBS +=
# Treat warnings as errors
win32:QMAKE_CXXFLAGS += /WX
CONFIG(debug, debug|release){
# Debug build options
# Enable a read-only console window (i.e. for printf etc.)
# CONFIG += console
}
else{
# Release build options
# Enable a read-only console window (i.e. for printf etc.)
# CONFIG += console
}
To copy to clipboard, switch view to plain text mode
Bookmarks