Important: Please read the Qt Code of Conduct -

Qt Designer, layouts with setSpacing(0()); why?

  • Hi, i don't understand why designer generates these statements for many layouts:

    I'm now trying Qt Creator for the first time and i get this:
    error: expression cannot be used as a function

    I changed the margins and spacings in designer but it only shows the specific fields (like horizontal and vertical).
    Any suggestions?

  • Lifetime Qt Champion

    That i have never seen before.
    What Qt version ?
    What Creator version ?
    What platform. linux/win/mac

    How exactly did you do to get this ?

    First you use standalone designer and then later in
    open the UI file in Creator?

    Please tell step, by step.

  • @mrjj

    Arch-Linux, Qt 5.13
    I'm using a UI that was created in Designer which i used before with PyQt. From within designer i can already see this weird setSpacing(0()) by using the menu: Form -> View Code... So far i haven't been able to recreate this behavior in a new UI.

  • Lifetime Qt Champion

    maybe the file was damaged or something like that.

  • @mrjj
    I have no indication of such a problem. I can open, save as, copy etc.

    Whatever goes wrong manifests in the stage of compiling the Qt User Interface.

  • Lifetime Qt Champion

    But if you make new UI , such code is not generated?
    I assume its the pythons version of uic you are using ?
    Did you look in the UI file if anything that look odd ?

  • @mrjj
    So far i haven't seen this code being generated in a new UI.

    I have uic and pyuic. If i generate a python version the code is normal.
    But if i use uic then i get this:

    I looked at the UI file and didn't see strange things. Though it's a lot of lines (3k+) and have not checked them all.

  • Lifetime Qt Champion

    ok so its only with c++ code gen, something odd happens.
    Any chance we can have the UI file to play with ?

  • @mrjj
    Thanks for trying to help me fix this but i'm not comfortable with sharing the UI file. Hope you understand.

    I will try to find the problem by eliminating code step by step. If i find something i will post the result.

  • Lifetime Qt Champion

    Yes, i understand.
    Its not always an option to share.

    Please update if you find something.

  • @mrjj

    OK here is what i found:

    <layoutdefault spacing="0" margin="0"/>
    <layoutfunction spacing="0" margin="0"/>

    After removing these 2 lines all the errors are gone.

    I have no idea why those lines were generated. They were near the bottom of the file and not inside other tags.
    Would be nice to know what caused this.

  • Found out where they come from. Designer menu: form settings.

    I had the layout function enabled and both fields set to zero. Instead of giving it a function name. Of course i don't even need (or understand) this functionality and should have left it alone. But this was many months ago when i first started with Qt. So today i found out i must think more before i click on something that seems harmless ;)

Log in to reply