I converted my .ui
file via uic
into a header file, which, as far as I know, contains the header AND the implementation of the .ui
file.
But what part of it is the header and what is the implementation?
Is there a way to seperate them properly?
#ifndef PATCHBOT_GUI_H
#define PATCHBOT_GUI_H
#include <QtCore/QVariant>
#include <QtGui/QIcon>
#include <QtWidgets/QApplication>
#include <QtWidgets/QComboBox>
#include <QtWidgets/QFrame>
#include <QtWidgets/QGridLayout>
#include <QtWidgets/QLabel>
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QMenuBar>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QScrollBar>
#include <QtWidgets/QStatusBar>
#include <QtWidgets/QTextEdit>
#include <QtWidgets/QVBoxLayout>
#include <QtWidgets/QWidget>
QT_BEGIN_NAMESPACE
class Ui_MainWindow
{
public:
QWidget *centralwidget;
QGridLayout *gridLayout;
QFrame *selectColonyFrame;
QPushButton *selectColonyButton;
QFrame *currentColonyFrame;
QLabel *currentColonyLabel;
QFrame *missionControlsFrame;
QVBoxLayout *verticalLayout;
QLabel *misisonControlsLabel;
QGridLayout *missionControlsGridLayout;
QPushButton *startButton;
QPushButton *abortButton;
QPushButton *singleStepButton;
QPushButton *autoButton;
QPushButton *pauseButton;
QFrame *botControlsFrame;
QGridLayout *gridLayout_2;
QGridLayout *botControlsGridLayout;
QPushButton *downButton;
QPushButton *upButton;
QPushButton *waitButton;
QPushButton *leftButton;
QPushButton *deleteButton;
QPushButton *rightButton;
QLabel *botControlsLabel;
QComboBox *repeatDropdown;
QFrame *frame_6;
QFrame *botCommandFrame;
QTextEdit *botCommandTextEdit;
QFrame *mapFrame;
QGridLayout *gridLayout_6;
QLabel *label;
QScrollBar *verticalScrollBar;
QScrollBar *horizontalScrollBar;
QMenuBar *menubar;
QStatusBar *statusbar;
void setupUi(QMainWindow *MainWindow)
{
if (MainWindow->objectName().isEmpty())
MainWindow->setObjectName(QString::fromUtf8("MainWindow"));
MainWindow->resize(819, 634);
MainWindow->setMinimumSize(QSize(580, 400));
centralwidget = new QWidget(MainWindow);
centralwidget->setObjectName(QString::fromUtf8("centralwidget"));
gridLayout = new QGridLayout(centralwidget);
gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
gridLayout->setVerticalSpacing(6);
gridLayout->setContentsMargins(-1, 0, -1, 0);
selectColonyFrame = new QFrame(centralwidget);
selectColonyFrame->setObjectName(QString::fromUtf8("selectColonyFrame"));
selectColonyFrame->setMinimumSize(QSize(150, 40));
selectColonyFrame->setLayoutDirection(Qt::RightToLeft);
selectColonyFrame->setFrameShape(QFrame::StyledPanel);
selectColonyFrame->setFrameShadow(QFrame::Raised);
selectColonyButton = new QPushButton(selectColonyFrame);
selectColonyButton->setObjectName(QString::fromUtf8("selectColonyButton"));
selectColonyButton->setGeometry(QRect(80, 0, 150, 40));
selectColonyButton->setMinimumSize(QSize(150, 40));
selectColonyButton->setMaximumSize(QSize(150, 50));
QFont font;
font.setPointSize(11);
font.setBold(true);
font.setWeight(75);
selectColonyButton->setFont(font);
gridLayout->addWidget(selectColonyFrame, 0, 1, 1, 1);
currentColonyFrame = new QFrame(centralwidget);
currentColonyFrame->setObjectName(QString::fromUtf8("currentColonyFrame"));
QSizePolicy sizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
sizePolicy.setHorizontalStretch(0);
sizePolicy.setVerticalStretch(0);
sizePolicy.setHeightForWidth(currentColonyFrame->sizePolicy().hasHeightForWidth());
currentColonyFrame->setSizePolicy(sizePolicy);
currentColonyFrame->setMinimumSize(QSize(0, 25));
currentColonyFrame->setFrameShape(QFrame::StyledPanel);
currentColonyFrame->setFrameShadow(QFrame::Raised);
currentColonyLabel = new QLabel(currentColonyFrame);
currentColonyLabel->setObjectName(QString::fromUtf8("currentColonyLabel"));
currentColonyLabel->setGeometry(QRect(10, 10, 301, 16));
currentColonyLabel->setMinimumSize(QSize(220, 15));
currentColonyLabel->setMaximumSize(QSize(460, 25));
QFont font1;
font1.setPointSize(10);
currentColonyLabel->setFont(font1);
gridLayout->addWidget(currentColonyFrame, 0, 0, 1, 1);
missionControlsFrame = new QFrame(centralwidget);
missionControlsFrame->setObjectName(QString::fromUtf8("missionControlsFrame"));
QSizePolicy sizePolicy1(QSizePolicy::Preferred, QSizePolicy::Preferred);
sizePolicy1.setHorizontalStretch(8);
sizePolicy1.setVerticalStretch(8);
sizePolicy1.setHeightForWidth(missionControlsFrame->sizePolicy().hasHeightForWidth());
missionControlsFrame->setSizePolicy(sizePolicy1);
missionControlsFrame->setMaximumSize(QSize(300, 180));
missionControlsFrame->setFrameShape(QFrame::WinPanel);
missionControlsFrame->setFrameShadow(QFrame::Raised);
verticalLayout = new QVBoxLayout(missionControlsFrame);
verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
misisonControlsLabel = new QLabel(missionControlsFrame);
misisonControlsLabel->setObjectName(QString::fromUtf8("misisonControlsLabel"));
QFont font2;
font2.setPointSize(11);
misisonControlsLabel->setFont(font2);
misisonControlsLabel->setAlignment(Qt::AlignCenter);
verticalLayout->addWidget(misisonControlsLabel);
missionControlsGridLayout = new QGridLayout();
missionControlsGridLayout->setObjectName(QString::fromUtf8("missionControlsGridLayout"));
missionControlsGridLayout->setHorizontalSpacing(20);
missionControlsGridLayout->setVerticalSpacing(10);
missionControlsGridLayout->setContentsMargins(15, 20, 15, 0);
startButton = new QPushButton(missionControlsFrame);
startButton->setObjectName(QString::fromUtf8("startButton"));
startButton->setMinimumSize(QSize(80, 30));
startButton->setMaximumSize(QSize(130, 50));
QFont font3;
font3.setPointSize(12);
startButton->setFont(font3);
missionControlsGridLayout->addWidget(startButton, 0, 0, 1, 1);
abortButton = new QPushButton(missionControlsFrame);
abortButton->setObjectName(QString::fromUtf8("abortButton"));
abortButton->setMinimumSize(QSize(80, 30));
abortButton->setMaximumSize(QSize(130, 50));
abortButton->setFont(font3);
abortButton->setLayoutDirection(Qt::LeftToRight);
abortButton->setAutoDefault(false);
abortButton->setFlat(false);
missionControlsGridLayout->addWidget(abortButton, 0, 1, 1, 1);
singleStepButton = new QPushButton(missionControlsFrame);
singleStepButton->setObjectName(QString::fromUtf8("singleStepButton"));
singleStepButton->setMinimumSize(QSize(80, 30));
singleStepButton->setMaximumSize(QSize(130, 50));
singleStepButton->setFont(font3);
missionControlsGridLayout->addWidget(singleStepButton, 1, 0, 1, 1);
autoButton = new QPushButton(missionControlsFrame);
autoButton->setObjectName(QString::fromUtf8("autoButton"));
autoButton->setMinimumSize(QSize(80, 30));
autoButton->setMaximumSize(QSize(130, 50));
autoButton->setFont(font3);
autoButton->setLayoutDirection(Qt::LeftToRight);
autoButton->setAutoDefault(false);
autoButton->setFlat(false);
missionControlsGridLayout->addWidget(autoButton, 1, 1, 1, 1);
pauseButton = new QPushButton(missionControlsFrame);
pauseButton->setObjectName(QString::fromUtf8("pauseButton"));
pauseButton->setMinimumSize(QSize(80, 30));
pauseButton->setMaximumSize(QSize(130, 50));
pauseButton->setFont(font3);
pauseButton->setLayoutDirection(Qt::LeftToRight);
pauseButton->setAutoDefault(false);
pauseButton->setFlat(false);
missionControlsGridLayout->addWidget(pauseButton, 2, 1, 1, 1);
verticalLayout->addLayout(missionControlsGridLayout);
gridLayout->addWidget(missionControlsFrame, 3, 1, 1, 1);
botControlsFrame = new QFrame(centralwidget);
botControlsFrame->setObjectName(QString::fromUtf8("botControlsFrame"));
QSizePolicy sizePolicy2(QSizePolicy::Preferred, QSizePolicy::Preferred);
sizePolicy2.setHorizontalStretch(4);
sizePolicy2.setVerticalStretch(4);
sizePolicy2.setHeightForWidth(botControlsFrame->sizePolicy().hasHeightForWidth());
botControlsFrame->setSizePolicy(sizePolicy2);
botControlsFrame->setMinimumSize(QSize(160, 120));
botControlsFrame->setMaximumSize(QSize(320, 240));
botControlsFrame->setFrameShape(QFrame::WinPanel);
botControlsFrame->setFrameShadow(QFrame::Raised);
gridLayout_2 = new QGridLayout(botControlsFrame);
gridLayout_2->setObjectName(QString::fromUtf8("gridLayout_2"));
botControlsGridLayout = new QGridLayout();
botControlsGridLayout->setObjectName(QString::fromUtf8("botControlsGridLayout"));
botControlsGridLayout->setSizeConstraint(QLayout::SetMinimumSize);
downButton = new QPushButton(botControlsFrame);
downButton->setObjectName(QString::fromUtf8("downButton"));
downButton->setMinimumSize(QSize(30, 30));
downButton->setMaximumSize(QSize(50, 50));
downButton->setLayoutDirection(Qt::LeftToRight);
QIcon icon;
icon.addFile(QString::fromUtf8(":/grafics/grafics/pfeile/pfeil_unten.tga"), QSize(), QIcon::Normal, QIcon::Off);
downButton->setIcon(icon);
downButton->setIconSize(QSize(50, 50));
botControlsGridLayout->addWidget(downButton, 2, 1, 1, 1);
upButton = new QPushButton(botControlsFrame);
upButton->setObjectName(QString::fromUtf8("upButton"));
upButton->setMinimumSize(QSize(30, 30));
upButton->setMaximumSize(QSize(50, 50));
upButton->setSizeIncrement(QSize(0, 0));
QIcon icon1;
icon1.addFile(QString::fromUtf8(":/grafics/grafics/pfeile/pfeil_oben.tga"), QSize(), QIcon::Normal, QIcon::Off);
upButton->setIcon(icon1);
upButton->setIconSize(QSize(50, 50));
botControlsGridLayout->addWidget(upButton, 0, 1, 1, 1);
waitButton = new QPushButton(botControlsFrame);
waitButton->setObjectName(QString::fromUtf8("waitButton"));
waitButton->setMinimumSize(QSize(30, 30));
waitButton->setMaximumSize(QSize(50, 50));
QFont font4;
font4.setFamily(QString::fromUtf8("MS Shell Dlg 2"));
font4.setPointSize(15);
waitButton->setFont(font4);
waitButton->setContextMenuPolicy(Qt::DefaultContextMenu);
QIcon icon2;
QString iconThemeName = QString::fromUtf8("◀");
if (QIcon::hasThemeIcon(iconThemeName)) {
icon2 = QIcon::fromTheme(iconThemeName);
} else {
icon2.addFile(QString::fromUtf8("."), QSize(), QIcon::Normal, QIcon::Off);
}
waitButton->setIcon(icon2);
botControlsGridLayout->addWidget(waitButton, 1, 1, 1, 1);
leftButton = new QPushButton(botControlsFrame);
leftButton->setObjectName(QString::fromUtf8("leftButton"));
leftButton->setMinimumSize(QSize(30, 30));
leftButton->setMaximumSize(QSize(50, 50));
QIcon icon3;
icon3.addFile(QString::fromUtf8(":/grafics/grafics/pfeile/pfeil_links.tga"), QSize(), QIcon::Normal, QIcon::Off);
leftButton->setIcon(icon3);
leftButton->setIconSize(QSize(50, 50));
botControlsGridLayout->addWidget(leftButton, 1, 0, 1, 1);
deleteButton = new QPushButton(botControlsFrame);
deleteButton->setObjectName(QString::fromUtf8("deleteButton"));
deleteButton->setMinimumSize(QSize(30, 30));
deleteButton->setMaximumSize(QSize(50, 50));
QFont font5;
font5.setPointSize(15);
deleteButton->setFont(font5);
botControlsGridLayout->addWidget(deleteButton, 0, 2, 1, 1);
rightButton = new QPushButton(botControlsFrame);
rightButton->setObjectName(QString::fromUtf8("rightButton"));
rightButton->setMinimumSize(QSize(30, 30));
rightButton->setMaximumSize(QSize(50, 50));
rightButton->setSizeIncrement(QSize(0, 0));
QIcon icon4;
icon4.addFile(QString::fromUtf8(":/grafics/grafics/pfeile/pfeil_rechts.tga"), QSize(), QIcon::Normal, QIcon::Off);
rightButton->setIcon(icon4);
rightButton->setIconSize(QSize(50, 50));
botControlsGridLayout->addWidget(rightButton, 1, 2, 1, 1);
gridLayout_2->addLayout(botControlsGridLayout, 1, 0, 3, 1);
botControlsLabel = new QLabel(botControlsFrame);
botControlsLabel->setObjectName(QString::fromUtf8("botControlsLabel"));
botControlsLabel->setFont(font2);
botControlsLabel->setAlignment(Qt::AlignCenter);
gridLayout_2->addWidget(botControlsLabel, 0, 0, 1, 2);
repeatDropdown = new QComboBox(botControlsFrame);
repeatDropdown->addItem(QString());
repeatDropdown->addItem(QString());
repeatDropdown->addItem(QString());
repeatDropdown->addItem(QString());
repeatDropdown->addItem(QString());
repeatDropdown->setObjectName(QString::fromUtf8("repeatDropdown"));
repeatDropdown->setMinimumSize(QSize(80, 30));
repeatDropdown->setMaximumSize(QSize(130, 50));
QFont font6;
font6.setPointSize(15);
font6.setBold(true);
font6.setItalic(false);
font6.setWeight(75);
repeatDropdown->setFont(font6);
repeatDropdown->setFocusPolicy(Qt::WheelFocus);
repeatDropdown->setLayoutDirection(Qt::LeftToRight);
repeatDropdown->setInsertPolicy(QComboBox::NoInsert);
repeatDropdown->setFrame(true);
gridLayout_2->addWidget(repeatDropdown, 1, 1, 1, 1);
frame_6 = new QFrame(botControlsFrame);
frame_6->setObjectName(QString::fromUtf8("frame_6"));
frame_6->setFrameShape(QFrame::StyledPanel);
frame_6->setFrameShadow(QFrame::Raised);
gridLayout_2->addWidget(frame_6, 2, 1, 1, 1);
botCommandFrame = new QFrame(botControlsFrame);
botCommandFrame->setObjectName(QString::fromUtf8("botCommandFrame"));
botCommandFrame->setMinimumSize(QSize(100, 80));
botCommandFrame->setMaximumSize(QSize(130, 16777215));
botCommandFrame->setFrameShape(QFrame::StyledPanel);
botCommandFrame->setFrameShadow(QFrame::Raised);
botCommandTextEdit = new QTextEdit(botCommandFrame);
botCommandTextEdit->setObjectName(QString::fromUtf8("botCommandTextEdit"));
botCommandTextEdit->setGeometry(QRect(0, 16, 108, 50));
QSizePolicy sizePolicy3(QSizePolicy::Expanding, QSizePolicy::Expanding);
sizePolicy3.setHorizontalStretch(130);
sizePolicy3.setVerticalStretch(50);
sizePolicy3.setHeightForWidth(botCommandTextEdit->sizePolicy().hasHeightForWidth());
botCommandTextEdit->setSizePolicy(sizePolicy3);
botCommandTextEdit->setMinimumSize(QSize(80, 30));
botCommandTextEdit->setMaximumSize(QSize(130, 50));
botCommandTextEdit->setFont(font5);
botCommandTextEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
botCommandTextEdit->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
botCommandTextEdit->setLineWrapMode(QTextEdit::NoWrap);
botCommandTextEdit->setReadOnly(true);
gridLayout_2->addWidget(botCommandFrame, 3, 1, 1, 1);
gridLayout_2->setRowStretch(1, 2);
gridLayout_2->setRowStretch(2, 1);
gridLayout_2->setRowStretch(3, 1);
gridLayout->addWidget(botControlsFrame, 1, 1, 2, 1);
mapFrame = new QFrame(centralwidget);
mapFrame->setObjectName(QString::fromUtf8("mapFrame"));
QSizePolicy sizePolicy4(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
sizePolicy4.setHorizontalStretch(0);
sizePolicy4.setVerticalStretch(0);
sizePolicy4.setHeightForWidth(mapFrame->sizePolicy().hasHeightForWidth());
mapFrame->setSizePolicy(sizePolicy4);
mapFrame->setMinimumSize(QSize(120, 120));
mapFrame->setFrameShape(QFrame::StyledPanel);
mapFrame->setFrameShadow(QFrame::Raised);
gridLayout_6 = new QGridLayout(mapFrame);
gridLayout_6->setSpacing(0);
gridLayout_6->setObjectName(QString::fromUtf8("gridLayout_6"));
label = new QLabel(mapFrame);
label->setObjectName(QString::fromUtf8("label"));
sizePolicy4.setHeightForWidth(label->sizePolicy().hasHeightForWidth());
label->setSizePolicy(sizePolicy4);
label->setMinimumSize(QSize(0, 0));
label->setFrameShape(QFrame::Box);
label->setAlignment(Qt::AlignCenter);
gridLayout_6->addWidget(label, 0, 0, 1, 1);
verticalScrollBar = new QScrollBar(mapFrame);
verticalScrollBar->setObjectName(QString::fromUtf8("verticalScrollBar"));
verticalScrollBar->setOrientation(Qt::Vertical);
gridLayout_6->addWidget(verticalScrollBar, 0, 1, 1, 1);
horizontalScrollBar = new QScrollBar(mapFrame);
horizontalScrollBar->setObjectName(QString::fromUtf8("horizontalScrollBar"));
QSizePolicy sizePolicy5(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
sizePolicy5.setHorizontalStretch(0);
sizePolicy5.setVerticalStretch(0);
sizePolicy5.setHeightForWidth(horizontalScrollBar->sizePolicy().hasHeightForWidth());
horizontalScrollBar->setSizePolicy(sizePolicy5);
horizontalScrollBar->setOrientation(Qt::Horizontal);
gridLayout_6->addWidget(horizontalScrollBar, 1, 0, 1, 1);
gridLayout->addWidget(mapFrame, 1, 0, 3, 1);
gridLayout->setRowStretch(0, 1);
gridLayout->setRowStretch(1, 4);
gridLayout->setRowStretch(2, 4);
gridLayout->setColumnStretch(0, 2);
gridLayout->setColumnMinimumWidth(0, 1);
gridLayout->setColumnMinimumWidth(1, 1);
gridLayout->setRowMinimumHeight(0, 1);
gridLayout->setRowMinimumHeight(1, 1);
gridLayout->setRowMinimumHeight(2, 10);
gridLayout->setRowMinimumHeight(3, 1);
MainWindow->setCentralWidget(centralwidget);
menubar = new QMenuBar(MainWindow);
menubar->setObjectName(QString::fromUtf8("menubar"));
menubar->setGeometry(QRect(0, 0, 819, 20));
MainWindow->setMenuBar(menubar);
statusbar = new QStatusBar(MainWindow);
statusbar->setObjectName(QString::fromUtf8("statusbar"));
MainWindow->setStatusBar(statusbar);
retranslateUi(MainWindow);
abortButton->setDefault(false);
autoButton->setDefault(false);
pauseButton->setDefault(false);
QMetaObject::connectSlotsByName(MainWindow);
} // setupUi
void retranslateUi(QMainWindow *MainWindow)
{
MainWindow->setWindowTitle(QCoreApplication::translate("MainWindow", "MainWindow", nullptr));
selectColonyButton->setText(QCoreApplication::translate("MainWindow", "Andere Kolonie ...", nullptr));
currentColonyLabel->setText(QCoreApplication::translate("MainWindow", "Aktuelle Kolonie: Lithium-Stollen 13-A", nullptr));
misisonControlsLabel->setText(QCoreApplication::translate("MainWindow", "Missionsablauf", nullptr));
startButton->setText(QCoreApplication::translate("MainWindow", "Start", nullptr));
abortButton->setText(QCoreApplication::translate("MainWindow", "Abbruch", nullptr));
singleStepButton->setText(QCoreApplication::translate("MainWindow", "Einzelschritt", nullptr));
autoButton->setText(QCoreApplication::translate("MainWindow", "Automatik", nullptr));
pauseButton->setText(QCoreApplication::translate("MainWindow", "Anhalten", nullptr));
downButton->setText(QString());
upButton->setText(QString());
waitButton->setText(QCoreApplication::translate("MainWindow", "W", nullptr));
leftButton->setText(QString());
deleteButton->setText(QCoreApplication::translate("MainWindow", "<", nullptr));
rightButton->setText(QString());
botControlsLabel->setText(QCoreApplication::translate("MainWindow", "Programmieren", nullptr));
repeatDropdown->setItemText(0, QCoreApplication::translate("MainWindow", "1", nullptr));
repeatDropdown->setItemText(1, QCoreApplication::translate("MainWindow", "2", nullptr));
repeatDropdown->setItemText(2, QCoreApplication::translate("MainWindow", "3", nullptr));
repeatDropdown->setItemText(3, QCoreApplication::translate("MainWindow", "4", nullptr));
repeatDropdown->setItemText(4, QCoreApplication::translate("MainWindow", "5", nullptr));
repeatDropdown->setCurrentText(QCoreApplication::translate("MainWindow", "1", nullptr));
botCommandTextEdit->setPlaceholderText(QCoreApplication::translate("MainWindow", "Textfeld", nullptr));
label->setText(QCoreApplication::translate("MainWindow", "Umgebungskarte", nullptr));
} // retranslateUi
};
namespace Ui {
class MainWindow: public Ui_MainWindow {};
} // namespace Ui
QT_END_NAMESPACE
#endif // PATCHBOT_GUI_H
Since I'm working with VS 2019 and have the "QT VS Tools" extension installed, I could also use the new "Convert Project to Qmake generated Project" tool. The problem here is, that I don't really know how it works.
I opened my .pro
file from Qt Designer with the "Open Qt project file..." funciton and then used the tool mentioned above. After the process finished, I didn't see any changes or new files. Did I miss something? Do I need to do something else?
If further information is needed, I'd be happy to help.
Basically the minimal Qt stand-alone example is two source files, one header file, and the UI XML file:
main
functionThe "main" source file could be very simple, all it does is create a
QApplication
object and theMainWindow
object. It shows the main window and then enters the application event loop:The "main window" header file start out also very simple:
And finally the "main window" implementation source file:
You also need to run the
uic
program to generate the needed source files from the UI XML file, and then build with the source file. You also need to use themoc
tool to resolve slots and signals.All of this should really be in most tutorials you will find online.