Qt Forum

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

    Unsolved How to resize contents in Qlistwidget

    General and Desktop
    3
    9
    1669
    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.
    • B
      Bharth last edited by

      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 Reply Quote 0
      • Kent-Dorfman
        Kent-Dorfman last edited by

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

        1 Reply Last reply Reply Quote 2
        • B
          Bharth last edited by

          i override resize event still messages are not resizing

          Kent-Dorfman 1 Reply Last reply Reply Quote 0
          • Kent-Dorfman
            Kent-Dorfman @Bharth last edited by

            @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 Reply Quote 0
            • SGaist
              SGaist Lifetime Qt Champion last edited by

              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 Reply Quote 0
              • B
                Bharth last edited by

                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 Reply Quote 0
                • B
                  Bharth @Kent-Dorfman last edited by

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

                  1 Reply Last reply Reply Quote 0
                  • Kent-Dorfman
                    Kent-Dorfman last edited by

                    @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 Reply Quote 0
                    • SGaist
                      SGaist Lifetime Qt Champion last edited by

                      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 Reply Quote 1
                      • First post
                        Last post