Solved QDialog showing as empty?
-
Hi guys,
So I've tried creating a QDialog but have run into a problem that I cannot figure out.
So I know that the dialog window is being created and built, but upon calling the
show();
function, the window seems to end up being empty. The code is as follows:
This function works perfectly:
void Lantease::on_help_aboutLantease_clicked() { Ui::AboutLantease win(new QDialog()); win.show(); win.exec(); }
These seem like they work appropriately:
Ui::AboutLantease::AboutLantease(QDialog *parent) : QDialog(parent) { setupUi(); } void Ui::AboutLantease::setupUi() { if(parent->objectName().isEmpty()) { parent->setObjectName(QStringLiteral("dialog_aboutLantease")); } parent->resize(800, 600); createWidgets(); createLayouts(); enableDebugLines(true); buildAboutDialog(); retranslateUi(); std::cout << "Was enabled" << std::endl; }
As I previously stated, the above works appropriately and I know this because I put cout calls in each function, all of which were outputted.
However, when the QDialog window is shown, it is completely empty AND there is no title, despite calling
setWindowTitle();
in retranslateUi().
Any ideas?
-
I suppose that AboutLantease inherits from QDialog. In this case don't use parent (only for initialization in constructor (...(QDialog *parent) :
QDialog(parent)...)). -
@Efreen do I just use "this" after that?
-
"This" Instead of parent or nothing, don't call to parent.
I mean:
Ui::AboutLantease::AboutLantease(QDialog *parent) : QDialog(parent) { setupUi(); } void Ui::AboutLantease::setupUi() { if(this->objectName().isEmpty()) { //or objectName().isEmpty() this->setObjectName(QStringLiteral("dialog_aboutLantease")); //or setObjectName(QStringLiteral } this->resize(800, 600); //or resize(800, 600) createWidgets(); createLayouts(); enableDebugLines(true); buildAboutDialog(); retranslateUi(); std::cout << "Was enabled" << std::endl; }