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 .ui ?
Forum Updated to NodeBB v4.3 + New Features

qscrollarea in .ui ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 1.4k 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.
  • S Offline
    S Offline
    stephane78
    wrote on last edited by
    #1

    HiH I have a problem with a qscrollarea that i have putted in the .ui and that doesn t work.
    My scrollareawidgetcontents has a vertical layout as the widget that it is it and i add qlabel in this widget and then call resize() to increase the heigth.my qscrollarea has the properties widgetresizable and adjusttocontents.
    The qscrollarea doesnt work.has anyone a good idea?

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by VRonin
      #2

      See https://forum.qt.io/topic/87379/qlabel-size-won-t-expand-even-after-setting-sizepolicy-to-expanding

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      4
      • S Offline
        S Offline
        stephane78
        wrote on last edited by
        #3

        Hi vronin and thanks but it is not exactly the same problem: i have a list of qlabel with text that i display in my widget and i want to scroll on it.if i put a addwidget on the layout when there are a lot of qlabel they are too small and the qscrollarea doesnt work.if i dont put addwidget i have the list of label but the qscrollarea doesnt work too and i dont see the end of the list.

        mrjjM VRoninV 2 Replies Last reply
        0
        • S stephane78

          Hi vronin and thanks but it is not exactly the same problem: i have a list of qlabel with text that i display in my widget and i want to scroll on it.if i put a addwidget on the layout when there are a lot of qlabel they are too small and the qscrollarea doesnt work.if i dont put addwidget i have the list of label but the qscrollarea doesnt work too and i dont see the end of the list.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @stephane78
          Hi
          Did you set Minimum size on the labels? did they become smaller when you added more?
          Also, why a "list" of Qlabels inside scrollarea ? you can get a much better working version
          with a List View / Widget. (if i may ask)

          1 Reply Last reply
          4
          • S stephane78

            Hi vronin and thanks but it is not exactly the same problem: i have a list of qlabel with text that i display in my widget and i want to scroll on it.if i put a addwidget on the layout when there are a lot of qlabel they are too small and the qscrollarea doesnt work.if i dont put addwidget i have the list of label but the qscrollarea doesnt work too and i dont see the end of the list.

            VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on last edited by VRonin
            #5

            @mrjj said in qscrollarea in .ui ?:

            Also, why a "list" of Qlabels inside scrollarea ? you can get a much better working version with a List View / Widget. (if i may ask)

            This is great advice


            @stephane78 said in qscrollarea in .ui ?:

            but it is not exactly the same problem

            I still disagree:

            #include <QApplication>
            #include <QScrollArea>
            #include <QLabel>
            #include <QVBoxLayout>
            #include <QPushButton>
            int main(int argc, char *argv[])
            {
                QApplication a(argc, argv);
                QWidget mainWid;
                QVBoxLayout* mainLay=new QVBoxLayout(&mainWid);
                QScrollArea* imageScroll = new QScrollArea(&mainWid);
                QWidget* scrollWidget = new QWidget;
                QVBoxLayout* scrollLay=new QVBoxLayout(scrollWidget);
                QPushButton* addLabelButton = new QPushButton("Add Label",&mainWid);
                imageScroll->setWidget(scrollWidget);
                QObject::connect(addLabelButton,&QPushButton::clicked,scrollWidget,[scrollLay,scrollWidget]()->void{
                    scrollLay->addWidget(new QLabel("Some Label",scrollWidget));
                    scrollWidget->resize(scrollWidget->sizeHint());
                });
                mainLay->addWidget(addLabelButton);
                mainLay->addWidget(imageScroll);
                mainWid.show();
                return a.exec();
            }
            

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            S 1 Reply Last reply
            2
            • VRoninV VRonin

              @mrjj said in qscrollarea in .ui ?:

              Also, why a "list" of Qlabels inside scrollarea ? you can get a much better working version with a List View / Widget. (if i may ask)

              This is great advice


              @stephane78 said in qscrollarea in .ui ?:

              but it is not exactly the same problem

              I still disagree:

              #include <QApplication>
              #include <QScrollArea>
              #include <QLabel>
              #include <QVBoxLayout>
              #include <QPushButton>
              int main(int argc, char *argv[])
              {
                  QApplication a(argc, argv);
                  QWidget mainWid;
                  QVBoxLayout* mainLay=new QVBoxLayout(&mainWid);
                  QScrollArea* imageScroll = new QScrollArea(&mainWid);
                  QWidget* scrollWidget = new QWidget;
                  QVBoxLayout* scrollLay=new QVBoxLayout(scrollWidget);
                  QPushButton* addLabelButton = new QPushButton("Add Label",&mainWid);
                  imageScroll->setWidget(scrollWidget);
                  QObject::connect(addLabelButton,&QPushButton::clicked,scrollWidget,[scrollLay,scrollWidget]()->void{
                      scrollLay->addWidget(new QLabel("Some Label",scrollWidget));
                      scrollWidget->resize(scrollWidget->sizeHint());
                  });
                  mainLay->addWidget(addLabelButton);
                  mainLay->addWidget(imageScroll);
                  mainWid.show();
                  return a.exec();
              }
              
              S Offline
              S Offline
              stephane78
              wrote on last edited by
              #6

              @VRonin and mrjj.yes it goes smaller when i add more qlabel even with setminimumsize and resize sizehint.but thank you for the advice, i will try with a qlistwidget.i think it is a good idea..thanks both...

              1 Reply Last reply
              1

              • Login

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