Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Change to Vertical Layout

    General and Desktop
    2
    4
    690
    Loading More Posts
    • 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.
    • T
      tactical77 last edited by

      Hi,

      I'm having problems with the layouts. I premade horizontal layout with the designer and have two widgets when the program starts. The 3rd added widget needs to be horizontal as well but the 4th one has to be vertically. I tried using QVBoxLayout but the widget didn't show up for some reason.

      jsulm 1 Reply Last reply Reply Quote 0
      • jsulm
        jsulm Lifetime Qt Champion @tactical77 last edited by

        @tactical77 You should show your code, so others can see what exactly you did.
        Also, you can use nested layouts: first QVBoxLayout, in it you put QHBoxLayout for horizontal widgets and you put the 4th widget directly into QVBoxLayout.

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        T 1 Reply Last reply Reply Quote 1
        • T
          tactical77 @jsulm last edited by

          @jsulm

          Here's the method.

          void MainWindow::on_tableWidget_cellDoubleClicked(int row, int column)
          {
          
              //item in qstring speichern dann in std string konvertieren
          
              //datum in qstring abspeichern
              QString von = QString::fromStdString(t.getAllBookings(row)->getFromDate());
              QString bis = QString::fromStdString(t.getAllBookings(row)->getToDate());
          
          
          
              //qcalenderwidget objekt wird erstellt
              QCalendarWidget *cal = new QCalendarWidget(this);
          
              //datum wird markiert
              cal->setSelectedDate(QDate::fromString(von, "yyyyMMdd"));
          
          
              //objekt wird dem fenster horizontal hinzugefuegt
              ui->horizontalLayout->addWidget(cal);
          
          
              //zweiter kalender mit end datum
              QCalendarWidget *cal2 = new QCalendarWidget(this);
          
          
              //datum wird markiert
              cal2->setSelectedDate(QDate::fromString(bis, "yyyyMMdd"));
          
              QWidget *window = new QWidget;
              QVBoxLayout *layout = new QVBoxLayout;
              layout->addWidget(cal2);
              window->setLayout(layout);
              window->show();
          
          
          
              
          
          }
          
          

          The 4th widget appears as a new window but I need it to be down by the 3rd widget.

          jsulm 1 Reply Last reply Reply Quote 0
          • jsulm
            jsulm Lifetime Qt Champion @tactical77 last edited by jsulm

            @tactical77 What is the 4th widget? I only see 3 widgets here (cal, cal2, window).
            Also window widget does not have a parent and that's why it is shown as a window.
            And as I suggested before: use vertical layout and put there first the horizontal layout and then the 4th widget...

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply Reply Quote 1
            • First post
              Last post