Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Do I need the private libraries in order to make a custom QGraphicsLayout?



  • First off; here is what I am trying to do:

    • Horizontal layout for Cards
    • Duplicate Cards are not drawn. Instead, a number representing how many are in the layout is written onto the first card.
    • If crowded, cards will overlap each other.
    • If you click a card, it will animate a fly from one layout to another.

    The documentation is kind of vague on what I should be doing here. It says

    You can use QGraphicsLayout as a base to write your own custom layout (e.g., a flowlayout), but it is more common to use one of its subclasses instead - QGraphicsLinearLayout or QGraphicsGridLayout.

    • To subclass the subclass, or to just use the subclass?

    Well I tried the former, by subclassing QGraphicsLayout, but found that I could not make anything work without the private classes, because Q_D is relied on quite a bit. I tried importing the private module but I had difficulty with it, because the source files for the private classes were not being detected causing vtable errors, and so I had to manually impliment them, which made a unworkable mess.

    I am not sure why. This was the line I was using in qbs.

    		Depends { name: "Qt.widgets-private"       }
    

    And so I tried subclassing QGraphicsLinearLayout, but I found that I could not change its behaviour really in any way. It again would appear from looking at its own implimentation, that I need the private classes.

    Anyways, all in all, my question is, do I need to be using the private libraries here, or am I way off track on what I am trying to do? And if so, is there a good place to familiarize myself with working with Qt's private libraries? I can't find documentation on things like the d_func pointer, or really what the purpose of having the private libraries in the first place is.

    Thanks.



  • @Kill-Animals said in Do I need the private libraries in order to make a custom QGraphicsLayout?:

    do I need to be using the private libraries here

    No. They are private to the Qt library itself for a reason.

    The subclasses that already exist layout items in non-overlapping areas (horizontally, vertically, or both). It sounds like you want something far more complex than that. If you want to handle this as a layout manager then you really have no choice but to subclass QGraphicsLayout.

    When you do that your subclass needs to implement its own logic for all of the pure virtual members and develop its own mechanisms for actually laying out the contained items. It should not need to reach into the private workings of the abstract QGraphicsLayout to achieve this.


Log in to reply