Important: Please read the Qt Code of Conduct -

Q_PROPERTY : problems with DESIGNABLE flag

  • Hi everyone,
    I'm using the Q_PROPERTY to create a table, and using the DESIGNABLE flag I want to make sure that one page is visible while in another no.

    Q_PROPERTY(QPointF Position READ Position DESIGNABLE false)

    With this code works, while if I try to replace with a function it will not work anymore.
    Can I put a function? Is there a way to custom it?

    Thank you

  • Lifetime Qt Champion


    You can't use a function there, it's a constant. Either you can use designer to modify that property or you can't.

    What exactly are you trying to achieve ?

  • I will try to explain it with a practical example.
    I have a rectangular object that has the property of the position. I create a property table where I insert the properties. This procedure is used in 2 separate pages, but I would like a page, such as a "print preview", not to display the position, but only other properties.
    The class I use to generate the table is always the same.

    I hope I have explained myself better.

  • Lifetime Qt Champion

    Then what about having a method in your class returning a list of the "previewable" properties ? Then you'd query only these properties in your "print preview" page and if you modify your class you only have to update that list of properties.

  • I would have preferred a quicker way using Q_PROPERTY, but I think the only way is what you've suggested to me.
    Thanks so much

Log in to reply