Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Layout gives wierd looking results.
Forum Updated to NodeBB v4.3 + New Features

Layout gives wierd looking results.

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 443 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    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:
    996db685-9b3b-42f2-9b63-b2e962fd1522-image.png

    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);
    
    }
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Looks like your widget is contained in something else.

      What happens if you instanciate completely standalone.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        @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.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            • ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #6

              Okay. Turns out I just didn't resize the widget

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved