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. Drawing Frames arround Widgets
Forum Updated to NodeBB v4.3 + New Features

Drawing Frames arround Widgets

Scheduled Pinned Locked Moved Solved General and Desktop
25 Posts 4 Posters 4.5k Views 2 Watching
  • 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.
  • S Offline
    S Offline
    sandro4912
    wrote on 4 Oct 2019, 18:16 last edited by sandro4912 10 Apr 2019, 18:17
    #11

    I could solve the Issue by removing the Space 0 here:

    auto mainLayout = new QVBoxLayout;
        //mainLayout->setSpacing(0);
        mainLayout->addWidget(mTopFrame);
        mainLayout->addWidget(mBottomFrame);
    

    Which gives:

    110f829d-24f0-4382-a414-ca3b200d02ff-image.png

    That looks pretty close to the original:

    b5a3a974-f0aa-4e07-867b-137dde40f3d0-image.png

    Although it looks like there is still some kind of space between the minefield and the frame? Can it be removed aswell?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 4 Oct 2019, 18:17 last edited by
      #12

      Hi
      It looks very much like the original
      How nostalgic :)

      1 Reply Last reply
      0
      • S Offline
        S Offline
        sandro4912
        wrote on 4 Oct 2019, 18:19 last edited by
        #13

        Yes the only Issue I still see is the remainig space between minefield and the bottomFrame.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 4 Oct 2019, 18:40 last edited by
          #14

          Hi
          There ?
          alt text

          1 Reply Last reply
          1
          • S Offline
            S Offline
            sandro4912
            wrote on 4 Oct 2019, 18:50 last edited by
            #15

            Yes in the original theres no space at all.

            I already throw out the top frame for testing to see if it causes it but still same result.

            M 1 Reply Last reply 4 Oct 2019, 19:12
            0
            • S sandro4912
              4 Oct 2019, 18:50

              Yes in the original theres no space at all.

              I already throw out the top frame for testing to see if it causes it but still same result.

              M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 4 Oct 2019, 19:12 last edited by
              #16

              @sandro4912
              Hi
              Im not sure where that space comes from as it seems you have it to zero

              auto bottomLayout = new QHBoxLayout;
              bottomLayout->setSpacing(0);
              bottomLayout->setContentsMargins(0,0,0,0);
              bottomLayout->addWidget(mMinefield);
              mBottomFrame->setLayout(bottomLayout);

              Did you try to raise the margins to see if you then get more space there ?

              S 1 Reply Last reply 5 Oct 2019, 09:47
              1
              • S Offline
                S Offline
                sandro4912
                wrote on 5 Oct 2019, 05:46 last edited by
                #17
                This post is deleted!
                1 Reply Last reply
                0
                • M mrjj
                  4 Oct 2019, 19:12

                  @sandro4912
                  Hi
                  Im not sure where that space comes from as it seems you have it to zero

                  auto bottomLayout = new QHBoxLayout;
                  bottomLayout->setSpacing(0);
                  bottomLayout->setContentsMargins(0,0,0,0);
                  bottomLayout->addWidget(mMinefield);
                  mBottomFrame->setLayout(bottomLayout);

                  Did you try to raise the margins to see if you then get more space there ?

                  S Offline
                  S Offline
                  sandro4912
                  wrote on 5 Oct 2019, 09:47 last edited by
                  #18

                  @mrjj

                  Yes if i rais the margin these spaces get higher. Still is very weired that 0 still gives these gaps.

                  I run the game in KDE Neon and Windows 10. On both OS is the same behaviour.

                  J 1 Reply Last reply 7 Oct 2019, 05:58
                  0
                  • S sandro4912
                    5 Oct 2019, 09:47

                    @mrjj

                    Yes if i rais the margin these spaces get higher. Still is very weired that 0 still gives these gaps.

                    I run the game in KDE Neon and Windows 10. On both OS is the same behaviour.

                    J Offline
                    J Offline
                    J.Hilk
                    Moderators
                    wrote on 7 Oct 2019, 05:58 last edited by
                    #19

                    hi @sandro4912 ,

                    my guess is, that the margins come from the mainLayout. You only set the setContentsMargins to 0 inside the bottomLayout, but the insert that layout into the mainLayout which has its own contentMargins still != 0


                    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                    Q: What's that?
                    A: It's blue light.
                    Q: What does it do?
                    A: It turns blue.

                    S 1 Reply Last reply 7 Oct 2019, 17:29
                    2
                    • J J.Hilk
                      7 Oct 2019, 05:58

                      hi @sandro4912 ,

                      my guess is, that the margins come from the mainLayout. You only set the setContentsMargins to 0 inside the bottomLayout, but the insert that layout into the mainLayout which has its own contentMargins still != 0

                      S Offline
                      S Offline
                      sandro4912
                      wrote on 7 Oct 2019, 17:29 last edited by
                      #20

                      @J-Hilk

                      No it still has the same Issue:

                          auto topLayout = new QHBoxLayout;
                          topLayout->setSpacing(0);
                          topLayout->setContentsMargins(0,0,0,0);
                          topLayout->addWidget(mLcdDisplayMinesLeft);
                          topLayout->addWidget(mSmileyPushButton);
                          topLayout->addWidget(mLcdDisplayElapsedTime);
                          mTopFrame->setLayout(topLayout);
                      
                          auto bottomLayout = new QHBoxLayout;
                          bottomLayout->setSpacing(0);
                          bottomLayout->setContentsMargins(0,0,0,0);
                          bottomLayout->addWidget(mMinefield);
                          mBottomFrame->setLayout(bottomLayout);
                      
                          auto mainLayout = new QVBoxLayout;
                          mainLayout->setSpacing(0);
                          mainLayout->setContentsMargins(0,0,0,0);
                          mainLayout->addWidget(mTopFrame);
                          mainLayout->addWidget(mBottomFrame);
                      
                          mMainFrame->setLayout(mainLayout);
                      
                          auto layout = new QVBoxLayout;
                          layout->setSpacing(0);
                          layout->setContentsMargins(0,0,0,0);
                          layout->addWidget(mMainFrame);
                      
                          setLayout(layout);
                      

                      Result:
                      e9de883c-65c2-4d40-8e1b-c83887644194-image.png

                      J 1 Reply Last reply 9 Oct 2019, 06:42
                      0
                      • S sandro4912
                        7 Oct 2019, 17:29

                        @J-Hilk

                        No it still has the same Issue:

                            auto topLayout = new QHBoxLayout;
                            topLayout->setSpacing(0);
                            topLayout->setContentsMargins(0,0,0,0);
                            topLayout->addWidget(mLcdDisplayMinesLeft);
                            topLayout->addWidget(mSmileyPushButton);
                            topLayout->addWidget(mLcdDisplayElapsedTime);
                            mTopFrame->setLayout(topLayout);
                        
                            auto bottomLayout = new QHBoxLayout;
                            bottomLayout->setSpacing(0);
                            bottomLayout->setContentsMargins(0,0,0,0);
                            bottomLayout->addWidget(mMinefield);
                            mBottomFrame->setLayout(bottomLayout);
                        
                            auto mainLayout = new QVBoxLayout;
                            mainLayout->setSpacing(0);
                            mainLayout->setContentsMargins(0,0,0,0);
                            mainLayout->addWidget(mTopFrame);
                            mainLayout->addWidget(mBottomFrame);
                        
                            mMainFrame->setLayout(mainLayout);
                        
                            auto layout = new QVBoxLayout;
                            layout->setSpacing(0);
                            layout->setContentsMargins(0,0,0,0);
                            layout->addWidget(mMainFrame);
                        
                            setLayout(layout);
                        

                        Result:
                        e9de883c-65c2-4d40-8e1b-c83887644194-image.png

                        J Offline
                        J Offline
                        J.Hilk
                        Moderators
                        wrote on 9 Oct 2019, 06:42 last edited by
                        #21

                        @sandro4912
                        mmh, strange.

                        I'm out of easy ideas to try 😞
                        sry


                        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                        Q: What's that?
                        A: It's blue light.
                        Q: What does it do?
                        A: It turns blue.

                        1 Reply Last reply
                        0
                        • M Offline
                          M Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on 9 Oct 2019, 06:59 last edited by
                          #22

                          Hi
                          What about INSIDE minefield ?
                          Did you use layout there ?

                          1 Reply Last reply
                          0
                          • S Offline
                            S Offline
                            sandro4912
                            wrote on 10 Oct 2019, 14:55 last edited by
                            #23

                            Yes inside the Minfield I place the Cells like this in the constructor:

                            auto layout = new QGridLayout;
                               layout->setSpacing(0);
                            
                               for(int i = 0; i < mCells.size(); ++i) {
                                   auto column = static_cast<int>(i %  mFieldWidth);
                                   auto row = static_cast<int>(i /  mFieldWidth);
                            
                                   layout->addWidget(mCells[i], row, column);
                               }
                            
                               setLayout(layout);
                            
                            M 1 Reply Last reply 10 Oct 2019, 14:57
                            0
                            • S sandro4912
                              10 Oct 2019, 14:55

                              Yes inside the Minfield I place the Cells like this in the constructor:

                              auto layout = new QGridLayout;
                                 layout->setSpacing(0);
                              
                                 for(int i = 0; i < mCells.size(); ++i) {
                                     auto column = static_cast<int>(i %  mFieldWidth);
                                     auto row = static_cast<int>(i /  mFieldWidth);
                              
                                     layout->addWidget(mCells[i], row, column);
                                 }
                              
                                 setLayout(layout);
                              
                              M Offline
                              M Offline
                              mrjj
                              Lifetime Qt Champion
                              wrote on 10 Oct 2019, 14:57 last edited by
                              #24

                              @sandro4912

                              But you dont seem to call setContentsMargins(0,0,0,0);
                              so maybe that is the space ?

                              S 1 Reply Last reply 10 Oct 2019, 15:27
                              2
                              • M mrjj
                                10 Oct 2019, 14:57

                                @sandro4912

                                But you dont seem to call setContentsMargins(0,0,0,0);
                                so maybe that is the space ?

                                S Offline
                                S Offline
                                sandro4912
                                wrote on 10 Oct 2019, 15:27 last edited by
                                #25

                                @mrjj said in Drawing Frames arround Widgets:

                                setContentsMargins(0,0,0,0);

                                thats it!

                                d4167070-a480-4188-9923-57d57cb94d35-image.png

                                I thought i tryed it before but i think i tryed:

                                setContentsMargins(0,0,0,0);
                                

                                and not

                                layout->setContentsMargins(0,0,0,0);
                                
                                1 Reply Last reply
                                2

                                20/25

                                7 Oct 2019, 17:29

                                • Login

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