Qt World Summit: Register Today!

Widget problem with out-of-bounds layout

  • 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.

  • Lifetime Qt Champion

    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 ?

  • @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?

  • Lifetime Qt Champion

    You cannot use the
    to add or remove air for the layout?

    Or do i completely miss what you want ?

  • Lifetime Qt Champion

    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.

  • @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.

    Twitter App

    (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.

Log in to reply