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. Widget problem with out-of-bounds layout
Qt 6.11 is out! See what's new in the release blog

Widget problem with out-of-bounds layout

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

    I inherited QLayout from Qt to create a new layout.

    However, if the layout widget is not drawn on the screen but needs to be located outside the layout area,

    if I specify the location with the setGeometry function,
    it will not be displayed but will be out of the area. How can I solve this problem in this case?

    This is my result.

    This is my current situation. The red area is the area of ​​the layout.

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

      Hi and welcome to devnet,

      Sorry but your explanation is a bit unclear. Can you maybe post a schematic of what you would like achieve ?

      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
      3
      • Q Offline
        Q Offline
        QtMakesPowerful
        wrote on last edited by QtMakesPowerful
        #3

        @SGaist

        English is not my native language and my grammar skills are not good. I apologize to you.

        If QListView or QListWidget has a lot of data, it is very slow or the program does not run.

        So, I am creating the QListView widget myself.

        I succeeded in creating a list of widgets. but, have some problem.

        class ListLayout: public QLayout
        

        Currently, ListLayout overrides setGeometry to specify the location of widgets that make up each list.

        The code that causes the problem is shown below.

        void ListLayout::setGeometry(const QRect &layout){
            QLayoutItem * layoutItem = ... ; 
            QRect pos (layout.x (), layout.y () - 50, layout.width(), 100); 
            
            // QRect pos (layout.x (), layout.y (), layout.width(), 50);
            // it changes the size of the widget.
            
            layoutItem-> setGeometry (pos);
        }
        

        My intention is that the widget displays only 50px from the bottom, but in the program it displays 100px altogether and the height of the widget is specified as the height of the layout - 50px.

        So, is there a way to not draw 50px from the top of the layout's widget?

        mrjjM 1 Reply Last reply
        0
        • Q QtMakesPowerful

          @SGaist

          English is not my native language and my grammar skills are not good. I apologize to you.

          If QListView or QListWidget has a lot of data, it is very slow or the program does not run.

          So, I am creating the QListView widget myself.

          I succeeded in creating a list of widgets. but, have some problem.

          class ListLayout: public QLayout
          

          Currently, ListLayout overrides setGeometry to specify the location of widgets that make up each list.

          The code that causes the problem is shown below.

          void ListLayout::setGeometry(const QRect &layout){
              QLayoutItem * layoutItem = ... ; 
              QRect pos (layout.x (), layout.y () - 50, layout.width(), 100); 
              
              // QRect pos (layout.x (), layout.y (), layout.width(), 50);
              // it changes the size of the widget.
              
              layoutItem-> setGeometry (pos);
          }
          

          My intention is that the widget displays only 50px from the bottom, but in the program it displays 100px altogether and the height of the widget is specified as the height of the layout - 50px.

          So, is there a way to not draw 50px from the top of the layout's widget?

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

          @QtMakesPowerful
          Hi
          You cannot use the
          http://doc.qt.io/qt-5/qlayout.html#contentsMargins
          to add or remove air for the layout?

          Or do i completely miss what you want ?

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

            You are replacing QListView with basically a list of widgets ? You do realise that it's way more expensive ? If you have that much data to handle, then you should rather implement a model that optimises the access to your data.

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

            Q 1 Reply Last reply
            1
            • SGaistS SGaist

              You are replacing QListView with basically a list of widgets ? You do realise that it's way more expensive ? If you have that much data to handle, then you should rather implement a model that optimises the access to your data.

              Q Offline
              Q Offline
              QtMakesPowerful
              wrote on last edited by QtMakesPowerful
              #6

              @SGaist I also tried to implement it by optimizing the model or overriding the paint method.
              Because I wanted to interact with QListView using SQLite. But, it did not work out.
              Thus, a layout that displays a list of direct implementations is not a problem for more than a million data items.

              However, one of the difficulties for me was that it was very difficult for a QListView to control the detailed events of a widget, such as the click event of each widget, for complex widgets containing multiple widgets.
              This is one of the instruments that I have implemented myself.

              I was expecting an object like ListView or RecyclerView of Android that I saw at the time of developing an existing Java based Android application, but the QListView <-> Model, system was far away from the ones that were excited.

              0_1538178862386_e80al.jpg
              Twitter App

              0_1538178594116_qml-modelviews-example.png
              (Source: http://doc.qt.io/qt-5/qtquick-views-example.html)

              This screen is an example of the screen I want. In my case, QListView was difficult to display tens of millions of rows. Also, if any changes were made, it did not seem easy to manage.

              @mrjj It is not the answer I want. I am sorry for my lack of explanation.

              This problem has not been solved, but I finished it in the way I want to.

              thank you for the reply.

              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