Layout gives wierd looking results.
-
Hello. In my main windows, I have a widget called PortalWidget. I added a layout to it, but it results in a weird look.
The resulting look:
The lines are a QLabel and a QComboBox.
This is my code for the PortalWidget constructor:
PortalWidget::PortalWidget(QWidget *parent) : QWidget{parent} { this->move(0, 30); IDLabel = new QLabel(this); char idText[21]; Portal* portal = Portal::GetPortal(); sprintf(idText, "Portal ID: 0x%X 0x%X", portal->Id[0], portal->Id[1]); IDLabel->setText(tr(idText)); connect(portal, &Portal::StateChanged, this, &PortalWidget::PortalUpdated); colorPicker = new QColorDialog(this); colorPicker->setWindowTitle(tr("Select portal color")); connect(colorPicker, &QColorDialog::colorSelected, this, &PortalWidget::ColorSelected); colorPicker->show(); sideSelector = new QComboBox(this); sideSelector->addItem(tr("All")); sideSelector->addItem(tr("Left")); sideSelector->addItem(tr("Right")); if(!Portal::GetPortal()->features.sidedColor) { sideSelector->setEditable(false); sideSelector->setCurrentIndex(0); } else { sideSelector->setEditable(true); } sideSelector->setToolTip(tr("Select the portal side to change the color")); QGridLayout* layout = new QGridLayout; layout->addWidget(IDLabel, 0, 0); layout->addWidget(sideSelector, 1, 0); setLayout(layout); }
-
Hi,
Looks like your widget is contained in something else.
What happens if you instanciate completely standalone.
-
@SGaist said in Layout gives wierd looking results.:
What happens if you instanciate completely standalone.
If I instantiate the PortalWidget standalone it just doesn't show up. It's contained within the main window.
-
Now your job is to instanciate that widget standalone and show it. There should be no need at this point of your main window for that at least based on the code you showed.
-
I want the widget to show inside the main window. I don't want it to be stand-alone. I want to have multiple menus that I can have open so I figured I split them into widgets. I'm very new to QT. If I instantiate it like this:
portalMenu = new PortalWidget(); portalMenu->show();
It opens as a standalone window, which I don't want.
-
Okay. Turns out I just didn't resize the widget