Hello all,
I'm having an issue wherein for a particular .ui file, the auto-generated ui header is trying to include the core class header, and failing.
That is, I have a QWidget-derived class, called slimWindow, and when building via Qt Creator, it generates the ui_slimwindow.h file, which tries to #include "slimwindow.h", which of course fails (that file doesn't get moved to the .ui directory during build).
The odd thing is, this error started when the class was moved from one subdirectory to another, even though the .pri file including it is correct, and everything works otherwise. I have many other ui files, and none of the rest do this. Telling in the symptoms is that the generated ui header doesn't declare the new object as a QWidget, like all of the other QWidget-derived headers, but instead declares it an instance of its own class, see:
/********************************************************************************
** Form generated from reading UI file 'slimwindow.ui'
**
** Created: Tue Jun 12 17:19:52 2012
** by: Qt User Interface Compiler version 4.8.0
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_SLIMWINDOW_H
#define UI_SLIMWINDOW_H
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QGridLayout>
#include <QtGui/QHBoxLayout>
#include <QtGui/QHeaderView>
#include <QtGui/QLineEdit>
#include <QtGui/QPushButton>
#include <QtGui/QSpacerItem>
#include <QtGui/QTableView>
#include <QtGui/QTextEdit>
#include "slimwindow.h"
QT_BEGIN_NAMESPACE
class Ui_SlimWindow
{
public:
void setupUi(SlimWindow *SlimWindow)
...
/********************************************************************************
** Form generated from reading UI file 'slimwindow.ui'
**
** Created: Tue Jun 12 17:19:52 2012
** by: Qt User Interface Compiler version 4.8.0
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_SLIMWINDOW_H
#define UI_SLIMWINDOW_H
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QGridLayout>
#include <QtGui/QHBoxLayout>
#include <QtGui/QHeaderView>
#include <QtGui/QLineEdit>
#include <QtGui/QPushButton>
#include <QtGui/QSpacerItem>
#include <QtGui/QTableView>
#include <QtGui/QTextEdit>
#include "slimwindow.h"
QT_BEGIN_NAMESPACE
class Ui_SlimWindow
{
public:
QGridLayout *gridLayout_2;
QGridLayout *gridLayout;
QHBoxLayout *horizontalLayout_2;
QSpacerItem *horizontalSpacer;
QLineEdit *commandInputLine;
QPushButton *goButton;
QHBoxLayout *horizontalLayout_4;
QTableView *historyTableView;
QTextEdit *commandResults;
void setupUi(SlimWindow *SlimWindow)
...
To copy to clipboard, switch view to plain text mode
Whereas, for all other QWidget-derived classes with ui files, the generated code looks as follows:
...
#include <QtGui/QLabel>
#include <QtGui/QListView>
#include <QtGui/QPushButton>
#include <QtGui/QScrollArea>
#include <QtGui/QSpacerItem>
#include <QtGui/QSpinBox>
#include <QtGui/QToolButton>
#include <QtGui/QVBoxLayout>
#include <QtGui/QWidget>
QT_BEGIN_NAMESPACE
class Ui_filmWindow
{
...
...
...
#include <QtGui/QLabel>
#include <QtGui/QListView>
#include <QtGui/QPushButton>
#include <QtGui/QScrollArea>
#include <QtGui/QSpacerItem>
#include <QtGui/QSpinBox>
#include <QtGui/QToolButton>
#include <QtGui/QVBoxLayout>
#include <QtGui/QWidget>
QT_BEGIN_NAMESPACE
class Ui_filmWindow
{
...
QPushButton *pushButton_11;
QPushButton *pushButton_10;
QPushButton *pushButton_9;
void setupUi(QWidget *filmWindow)
...
To copy to clipboard, switch view to plain text mode
This happens on both OSX and Windows during compile. I know that I can change include paths and the issue will "disappear", but that seems like a cover-up over a bigger problem. Has anyone seen similar behavior before? I saw one post regarding it, but the suggested, and followed, solution was to cover up the issue by modifying the include paths so that including a file not in the current directory would work.
Without posting mountains of code, as the project is fairly complex I'm hoping the following parts will be sufficient in pointing out what I might've done wrong?:
slim.pri:
DEFINES += QT_USE_QSTRINGBUILDER
HEADERS += \
slim/slimwindow.h \
slim/SlimFileHandler/slimfilehandler.h
SOURCES += \
slim/slimwindow.cpp \
slim/SlimFileHandler/slimfilehandler.cpp
FORMS += \
slim/slimwindow.ui
DEFINES += QT_USE_QSTRINGBUILDER
HEADERS += \
slim/slimwindow.h \
slim/SlimFileHandler/slimfilehandler.h
SOURCES += \
slim/slimwindow.cpp \
slim/SlimFileHandler/slimfilehandler.cpp
FORMS += \
slim/slimwindow.ui
To copy to clipboard, switch view to plain text mode
slimwindow.h:
#ifndef SLIMWINDOW_H
#define SLIMWINDOW_H
#include <QWidget>
#include <QString>
#include "MoCoBus/omcommandbuffer.h"
#include "MoCoBus/omnetwork.h"
#include "Slim/commandhistorymodel.h"
#include "Slim/slimcommandparser.h"
namespace Ui {
class SlimWindow;
}
{
Q_OBJECT
public:
SlimWindow
(OMNetwork
* net, CommandHistoryModel
* hist, SlimCommandParser
* parse,
QWidget *parent
= 0);
~SlimWindow();
private slots:
void onCmdEntry();
void onCmdResult(slimCommand);
public slots:
void registerNewDevice(OMbusInfo* p_bus, OMdeviceInfo* p_dev);
void removeDevice(OMbusInfo* p_bus, unsigned short p_addr);
private:
Ui::SlimWindow *ui;
CommandHistoryModel* _cmdHist;
OMNetwork* _net;
SlimCommandParser * _parser;
};
#endif // SLIMWINDOW_H
#ifndef SLIMWINDOW_H
#define SLIMWINDOW_H
#include <QWidget>
#include <QString>
#include "MoCoBus/omcommandbuffer.h"
#include "MoCoBus/omnetwork.h"
#include "Slim/commandhistorymodel.h"
#include "Slim/slimcommandparser.h"
namespace Ui {
class SlimWindow;
}
class SlimWindow : public QWidget
{
Q_OBJECT
public:
SlimWindow(OMNetwork* net, CommandHistoryModel* hist, SlimCommandParser* parse, QWidget *parent = 0);
~SlimWindow();
private slots:
void onCmdEntry();
void onCmdResult(slimCommand);
public slots:
void registerNewDevice(OMbusInfo* p_bus, OMdeviceInfo* p_dev);
void removeDevice(OMbusInfo* p_bus, unsigned short p_addr);
private:
Ui::SlimWindow *ui;
CommandHistoryModel* _cmdHist;
OMNetwork* _net;
SlimCommandParser * _parser;
};
#endif // SLIMWINDOW_H
To copy to clipboard, switch view to plain text mode
slimwindow.cpp (just up to, and including, the constructor) :
#include "slimwindow.h"
#include "ui_slimwindow.h"
#include <QDebug>
#include <QtEndian>
#include "Core/ErrorDialog/errordialog.h"
SlimWindow
::SlimWindow(OMNetwork
* net, CommandHistoryModel
* hist, SlimCommandParser
* parse,
QWidget *parent
) : ui(new Ui::SlimWindow)
{
ui->setupUi(this);
_parser = parse;
_net = net;
_cmdHist = hist;
ui->historyTableView->setModel(_cmdHist);
QObject::connect(_cmdHist,
SIGNAL(commandResults
(slimCommand
)),
this,
SLOT(onCmdResult
(slimCommand
)), Qt
::QueuedConnection);
}
#include "slimwindow.h"
#include "ui_slimwindow.h"
#include <QDebug>
#include <QtEndian>
#include "Core/ErrorDialog/errordialog.h"
SlimWindow::SlimWindow(OMNetwork* net, CommandHistoryModel* hist, SlimCommandParser* parse, QWidget *parent) :
QWidget(parent),
ui(new Ui::SlimWindow)
{
ui->setupUi(this);
_parser = parse;
_net = net;
_cmdHist = hist;
ui->historyTableView->setModel(_cmdHist);
QObject::connect(_cmdHist, SIGNAL(commandResults(slimCommand)), this, SLOT(onCmdResult(slimCommand)), Qt::QueuedConnection);
}
To copy to clipboard, switch view to plain text mode
Bookmarks