我在将一些组件从代码设置为使用 qt creator 创建的布局时遇到问题我正在尝试添加组件,当我运行我的窗口时,组件没有显示在这里是一些代码 SlotPLayerWidget 是我创建的一个小部件使用 qt 创建者
'#include "joinwidget.h"
#include "ui_joinwidget.h"
#include "ui/joingameteamselectionwidget.h"
#include <QDebug>
JoinWidget::JoinWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::JoinWidget)
{
ui->setupUi(this);
this->createPlayersSlots(8);
}
JoinWidget::~JoinWidget()
{
delete ui;
}
void JoinWidget::on_exitButton_clicked()
{
exit(0);
}
void JoinWidget::on_startGameButton_clicked()
{
//start game
}
void JoinWidget::on_mainMenuButton_clicked()
{
emit mainMenuButtonClicked();
}
void JoinWidget::setPlayerName(QString playerName){
this->playerName_ = playerName;
}
void JoinWidget::createPlayersSlots(int numberOfPlayers){
for(int i = 0;i< numberOfPlayers; i++){
SlotPlayerWidget widget;
ui->slotPlayersVerticalLayout->addWidget(&widget);
}
}'