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. QScrollarea in verticalLayout
Forum Updated to NodeBB v4.3 + New Features

QScrollarea in verticalLayout

Scheduled Pinned Locked Moved Solved General and Desktop
15 Posts 3 Posters 3.0k Views 2 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.
  • H Offline
    H Offline
    hjohn
    wrote on last edited by
    #6

    widget.cpp

    #include "widget.h"
    #include "ui_widget.h"
    
    #include<QScrollArea>
    #include<QPushButton>
    #include<QDebug>
    Widget::Widget(QWidget *parent) :
        QWidget(parent),
        ui(new Ui::Widget)
    {
        ui->setupUi(this);
    
        QWidget *W=new QWidget(this);
        
        W->setLayout(ui->verticalLayout);
    
    
    
        QScrollArea *area=new QScrollArea(this);
            area->setWidget(W);
    
    }
    
    Widget::~Widget()
    {
        delete ui;
    }
    
    

    output :
    0_1530867116274_1.png

    as its visible in the image , it doesn't look proper. How do I fix it ?

    raven-worxR 1 Reply Last reply
    0
    • H hjohn

      widget.cpp

      #include "widget.h"
      #include "ui_widget.h"
      
      #include<QScrollArea>
      #include<QPushButton>
      #include<QDebug>
      Widget::Widget(QWidget *parent) :
          QWidget(parent),
          ui(new Ui::Widget)
      {
          ui->setupUi(this);
      
          QWidget *W=new QWidget(this);
          
          W->setLayout(ui->verticalLayout);
      
      
      
          QScrollArea *area=new QScrollArea(this);
              area->setWidget(W);
      
      }
      
      Widget::~Widget()
      {
          delete ui;
      }
      
      

      output :
      0_1530867116274_1.png

      as its visible in the image , it doesn't look proper. How do I fix it ?

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #7

      @hjohn said in QScrollarea in verticalLayout:

      it doesn't look proper. How do I fix it ?

      define proper. What exactly do you want to achieve?

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      H 1 Reply Last reply
      0
      • raven-worxR raven-worx

        @hjohn said in QScrollarea in verticalLayout:

        it doesn't look proper. How do I fix it ?

        define proper. What exactly do you want to achieve?

        H Offline
        H Offline
        hjohn
        wrote on last edited by hjohn
        #8

        @raven-worx Proper:Without horizontal scrollBar, I mean if we want to see the whole button we have to scroll . I don't want to scroll horizontally.

        1 Reply Last reply
        0
        • H Offline
          H Offline
          hjohn
          wrote on last edited by
          #9

          Okay its done ,
          I just resized the QScrollArea.
          Thanks all.

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

            Hi,

            Since you are using Designer, why don't you put the QScrollArea directly in your ui ?

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

            H 1 Reply Last reply
            0
            • SGaistS SGaist

              Hi,

              Since you are using Designer, why don't you put the QScrollArea directly in your ui ?

              H Offline
              H Offline
              hjohn
              wrote on last edited by
              #11

              @SGaist I had to implement the QScrollArea by means of code.

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

                Why is that ?

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

                H 1 Reply Last reply
                0
                • SGaistS SGaist

                  Why is that ?

                  H Offline
                  H Offline
                  hjohn
                  wrote on last edited by
                  #13

                  @SGaist Firstly I used the ScrollArea from UI, and it worked fine, So I wanted use QScrollArea by code. Just for learning purpose.

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

                    Then I'd recommend to start by doing the whole interface in code only. Once you are confortable with that, you can start mixing designer and code generate widgets.

                    There are subtleties when mixing that you have to take into account.

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

                    H 1 Reply Last reply
                    1
                    • SGaistS SGaist

                      Then I'd recommend to start by doing the whole interface in code only. Once you are confortable with that, you can start mixing designer and code generate widgets.

                      There are subtleties when mixing that you have to take into account.

                      H Offline
                      H Offline
                      hjohn
                      wrote on last edited by
                      #15

                      @SGaist yeah thanks..

                      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