Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt Designer, layouts with setSpacing(0()); why?
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved Solved General and Desktop
12 Posts 2 Posters 899 Views
  • 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 Offline
    T Offline
    Tink
    wrote on last edited by Tink
    #1

    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
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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
      0
      • mrjjM mrjj

        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 Offline
        T Offline
        Tink
        wrote on last edited by
        #3

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

        mrjjM 1 Reply Last reply
        0
        • T Tink

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

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

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

          T 1 Reply Last reply
          0
          • mrjjM mrjj

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

            T Offline
            T Offline
            Tink
            wrote on last edited by Tink
            #5

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

            mrjjM 1 Reply Last reply
            0
            • T 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.

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @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
              1
              • mrjjM mrjj

                @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 Offline
                T Offline
                Tink
                wrote on last edited by
                #7

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

                mrjjM 1 Reply Last reply
                0
                • T Tink

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

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @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
                  1
                  • mrjjM mrjj

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

                    T Offline
                    T Offline
                    Tink
                    wrote on last edited by
                    #9

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

                    mrjjM 1 Reply Last reply
                    1
                    • T Tink

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

                      mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

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

                      Please update if you find something.

                      T 1 Reply Last reply
                      0
                      • mrjjM mrjj

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

                        Please update if you find something.

                        T Offline
                        T Offline
                        Tink
                        wrote on last edited by Tink
                        #11

                        @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
                        0
                        • T Offline
                          T Offline
                          Tink
                          wrote on last edited by Tink
                          #12

                          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
                          1

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved