Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

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

    General and Desktop
    2
    12
    373
    Loading More Posts
    • 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.
    • T
      Tink last edited by Tink

      Hi, i don't understand why designer generates these statements for many layouts:
      verticalLayout->setSpacing(0());
      verticalLayout->setMargin(0());

      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?

      1 Reply Last reply Reply Quote 0
      • mrjj
        mrjj Lifetime Qt Champion last edited by

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

        T 1 Reply Last reply Reply Quote 0
        • T
          Tink @mrjj last edited by

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

          mrjj 1 Reply Last reply Reply Quote 0
          • mrjj
            mrjj Lifetime Qt Champion @Tink last edited by

            @tink
            maybe the file was damaged or something like that.

            T 1 Reply Last reply Reply Quote 0
            • T
              Tink @mrjj last edited by Tink

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

              mrjj 1 Reply Last reply Reply Quote 0
              • mrjj
                mrjj Lifetime Qt Champion @Tink last edited by

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

                T 1 Reply Last reply Reply Quote 1
                • T
                  Tink @mrjj last edited by

                  @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.
                  self.gridLayout_1.setSpacing(0)
                  But if i use uic then i get this:
                  gridLayout_1->setSpacing(0());

                  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.

                  mrjj 1 Reply Last reply Reply Quote 0
                  • mrjj
                    mrjj Lifetime Qt Champion @Tink last edited by

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

                    T 1 Reply Last reply Reply Quote 1
                    • T
                      Tink @mrjj last edited by

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

                      mrjj 1 Reply Last reply Reply Quote 1
                      • mrjj
                        mrjj Lifetime Qt Champion @Tink last edited by

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

                        Please update if you find something.

                        T 1 Reply Last reply Reply Quote 0
                        • T
                          Tink @mrjj last edited by Tink

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

                          1 Reply Last reply Reply Quote 0
                          • T
                            Tink last edited by Tink

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

                            edit:
                            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 ;)

                            1 Reply Last reply Reply Quote 1
                            • First post
                              Last post