Reputation: 938
In Qt Creator UI Designer it is possible to replace a widget with its subclass. I have created a template subclass of QComboBox
:
template <typename T>
class MappedComboBox : public QComboBox
{
// ...
};
And I have successfully managed to replace QComboBox
with MappedComboBox<int>
. However replacing QComboBox
widget with, for instance, MappedComboBox<QSerialPort::BaudRate>
fails due to dependency errors while building like
'QSerialPort' was not declared in this scope.
Of course one way to get rid of them is to include QSerialPort
in mappedcombobox.h
however that's not a very elegant way. Can I somehow tell Qt Designer to include additional files while generating UI?
Upvotes: 1
Views: 718
Reputation: 188
In the UI designer there is no way to include an extra header. A better workaround is to include it in the cpp file of the designer class before including the generated header. That's better than including in the MappedComboBox which has no business with that header.
In mainwindow.cpp:
#include "mainwindow.h"
#include <QSerialPort>
#include "ui_mainwindow.h"
Upvotes: 0