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. How to resize contents in Qlistwidget

How to resize contents in Qlistwidget

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 3 Posters 2.6k 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.
  • B Offline
    B Offline
    Bharth
    wrote on last edited by
    #1

    hi,,,
    im doing chat application,,if i resize application messages are not showing and showing only when i did full screen please help me 0_1552395584987_1552395550007.JPEG

    how to resize contents(QLIstWidgetItem) in QListwidget

    thanks in advance0_1552395592412_1552395549936.JPEG

    1 Reply Last reply
    0
    • Kent-DorfmanK Offline
      Kent-DorfmanK Offline
      Kent-Dorfman
      wrote on last edited by
      #2

      reimplement resizeEvent() for the child widget contained in the scroll area.

      1 Reply Last reply
      2
      • B Offline
        B Offline
        Bharth
        wrote on last edited by
        #3

        i override resize event still messages are not resizing

        Kent-DorfmanK 1 Reply Last reply
        0
        • B Bharth

          i override resize event still messages are not resizing

          Kent-DorfmanK Offline
          Kent-DorfmanK Offline
          Kent-Dorfman
          wrote on last edited by
          #4

          @Bharth said in How to resize contents in Qlistwidget:

          i override resize event still messages are not resizing

          well, what is the substance of your resizeEvent() handler?

          anything like:

          this->resize(this->parent().size())
          
          B 1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Hi,

            Can you show the code you are currently using ?

            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
            • B Offline
              B Offline
              Bharth
              wrote on last edited by
              #6

              this is code im adding listwidgetiem (chatpage.cpp)

                     pListWidgetItem = new QListWidgetItem(ui->list_chat);
                      ui->list_chat->addItem(pListWidgetItem);
                      pChatCell = new ChatCell(this,pMessage,textmessage,strQuote,strDateTime,bFilter);
                      pListWidgetItem->setSizeHint(pChatCell->sizeHint());
                      ui->list_chat->setItemWidget(pListWidgetItem, pChatCell);
              

              void ChatPage::resizeEvent(QResizeEvent *event)
              {
              QSize size = this->size();
              if(pChatCell!=nullptr)
              {
              pChatCell->setMinimumWidth(size.width());
              pChatCell->setMinimumHeight(size.height());
              pChatCell->setMaximumWidth(size.width());
              pChatCell->setMaximumHeight(size.height());
              MainSubPage::resizeEvent(event);
              pListWidgetItem->sizeHint();
              }

              }

              here ChatCell is another widget

              1 Reply Last reply
              0
              • Kent-DorfmanK Kent-Dorfman

                @Bharth said in How to resize contents in Qlistwidget:

                i override resize event still messages are not resizing

                well, what is the substance of your resizeEvent() handler?

                anything like:

                this->resize(this->parent().size())
                
                B Offline
                B Offline
                Bharth
                wrote on last edited by
                #7

                @Kent-Dorfman
                where i have to add this chatpage(Qlistwidget) or chatcell(QlistwidgetItem)

                1 Reply Last reply
                0
                • Kent-DorfmanK Offline
                  Kent-DorfmanK Offline
                  Kent-Dorfman
                  wrote on last edited by
                  #8

                  @Bharth said in How to resize contents in Qlistwidget:

                  void ChatPage::resizeEvent(QResizeEvent *event)
                  {
                  QSize size = this->size();
                  if(pChatCell!=nullptr)
                  {
                  pChatCell->setMinimumWidth(size.width());
                  pChatCell->setMinimumHeight(size.height());
                  pChatCell->setMaximumWidth(size.width());
                  pChatCell->setMaximumHeight(size.height());
                  MainSubPage::resizeEvent(event);
                  pListWidgetItem->sizeHint();
                  }
                  }

                  Why are you changing the size constraints within the resize event? That's what size policies are for. Also, what happens if you try to setMinimumSize to a value greater than the current maximum size, or conversely you try to setMaximumSize less than the current minimum?

                  All I was suggesting is that you override the child resizeEvent to consider the available space that the parent has given it. I believe a resize in the parent will recursively call the resize for all of its children in a breadth first search pattern.

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

                    Why are you using a QScrollArea at all ?

                    QListView/Widget already handles that part if its content becomes bigger than the viewport.

                    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
                    1

                    • Login

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