Created
November 5, 2017 23:55
-
-
Save eyllanesc/732a0bdb1b194f4e6bd98e7fc89f5002 to your computer and use it in GitHub Desktop.
47127297
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#------------------------------------------------- | |
# | |
# Project created by QtCreator 2017-11-05T18:00:50 | |
# | |
#------------------------------------------------- | |
QT += core gui | |
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets | |
TARGET = example | |
TEMPLATE = app | |
# The following define makes your compiler emit warnings if you use | |
# any feature of Qt which has been marked as deprecated (the exact warnings | |
# depend on your compiler). Please consult the documentation of the | |
# deprecated API in order to know how to port your code away from it. | |
DEFINES += QT_DEPRECATED_WARNINGS | |
# You can also make your code fail to compile if you use deprecated APIs. | |
# In order to do so, uncomment the following line. | |
# You can also select to disable deprecated APIs only up to a certain version of Qt. | |
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 | |
SOURCES += \ | |
main.cpp | |
HEADERS += |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <QApplication> | |
#include <QPushButton> | |
#include <QVBoxLayout> | |
#include <QWidget> | |
#include <QLabel> | |
class LogWindow: public QWidget{ | |
Q_OBJECT | |
public: | |
LogWindow(const QString &text, QWidget *parent=Q_NULLPTR):QWidget(parent){ | |
setLayout(new QVBoxLayout); | |
btn = new QPushButton(text, this); | |
layout()->addWidget(btn); | |
connect(btn, &QPushButton::clicked, this, &LogWindow::customSignal); | |
} | |
signals: | |
void customSignal(); | |
private: | |
QPushButton *btn; | |
}; | |
class RegWindow : public QWidget{ | |
QLabel *label; | |
public: | |
RegWindow(const QString &text, QWidget *parent=Q_NULLPTR):QWidget(parent){ | |
setLayout(new QVBoxLayout); | |
label = new QLabel(text, this); | |
layout()->addWidget(label); | |
} | |
}; | |
int main(int argc, char *argv[]) | |
{ | |
QApplication a(argc, argv); | |
LogWindow *log= new LogWindow("LogWindow"); | |
RegWindow *reg; | |
QObject::connect(log, &LogWindow::customSignal, [®, &log](){ | |
reg = new RegWindow("RegWindow"); | |
reg->show(); | |
log->deleteLater(); | |
}); | |
log->show(); | |
return a.exec(); | |
} | |
#include "main.moc" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment