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. Change to Vertical Layout
QtWS25 Last Chance

Change to Vertical Layout

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 1.4k Views
  • 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 Offline
    T Offline
    tactical77
    wrote on 26 Apr 2019, 05:00 last edited by
    #1

    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.

    J 1 Reply Last reply 26 Apr 2019, 05:16
    0
    • T tactical77
      26 Apr 2019, 05:00

      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.

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 26 Apr 2019, 05:16 last edited by
      #2

      @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 26 Apr 2019, 06:19
      1
      • J jsulm
        26 Apr 2019, 05:16

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

        T Offline
        T Offline
        tactical77
        wrote on 26 Apr 2019, 06:19 last edited by
        #3

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

        J 1 Reply Last reply 26 Apr 2019, 06:48
        0
        • T tactical77
          26 Apr 2019, 06:19

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

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 26 Apr 2019, 06:48 last edited by jsulm
          #4

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

          2/4

          26 Apr 2019, 05:16

          • Login

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