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. Changing alignment of check boxes within QGrid
Forum Updated to NodeBB v4.3 + New Features

Changing alignment of check boxes within QGrid

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 1.7k Views 1 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.
  • O Offline
    O Offline
    Omni_Philm
    wrote on last edited by
    #1

    Hello all,

    I currently have a QGridLayout with checkboxes and labels. I am able to get the label horizontally aligned in the center. However, the alignment for my checkboxes and labels are off since the checkboxes are currently aligned to the left.

    I have been searching but haven't found anything yet, is there any way that I can make the checkboxes align to the center so that the checkboxes are aligned with my labels which are horizontally centered?

    Thank you

    jsulmJ 1 Reply Last reply
    0
    • O Omni_Philm

      Hello all,

      I currently have a QGridLayout with checkboxes and labels. I am able to get the label horizontally aligned in the center. However, the alignment for my checkboxes and labels are off since the checkboxes are currently aligned to the left.

      I have been searching but haven't found anything yet, is there any way that I can make the checkboxes align to the center so that the checkboxes are aligned with my labels which are horizontally centered?

      Thank you

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Omni_Philm When using https://doc.qt.io/qt-5/qgridlayout.html#addItem to add items you can specify alignment - did you?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      3
      • O Offline
        O Offline
        Omni_Philm
        wrote on last edited by
        #3

        @jsulm Thank you for your reply. I apologie that I did not mention this in my original posting. I am using the designer and I do not see that option. However, that is good to know in the future!

        Looking through the documentation, there is a setAlignment function for the QLayout class. I am assuming that I need to pass a pointer to the QWidget that I want to align to? I am looking at this function: https://doc.qt.io/qt-5/qlayout.html#setAlignment

        Is there a faster way of doing the two step process? If I have like 20 checkboxes in the layout, this can be quite tedious.

        mrjjM 1 Reply Last reply
        0
        • O Omni_Philm

          @jsulm Thank you for your reply. I apologie that I did not mention this in my original posting. I am using the designer and I do not see that option. However, that is good to know in the future!

          Looking through the documentation, there is a setAlignment function for the QLayout class. I am assuming that I need to pass a pointer to the QWidget that I want to align to? I am looking at this function: https://doc.qt.io/qt-5/qlayout.html#setAlignment

          Is there a faster way of doing the two step process? If I have like 20 checkboxes in the layout, this can be quite tedious.

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

          @Omni_Philm
          Hi
          You mean like this ?
          alt text

          alt text

          O 1 Reply Last reply
          2
          • mrjjM mrjj

            @Omni_Philm
            Hi
            You mean like this ?
            alt text

            alt text

            O Offline
            O Offline
            Omni_Philm
            wrote on last edited by
            #5

            @mrjj

            Aw man, you have got to be kidding me!!!! It was there the entire time!!! I feel silly now!

            Oh well, I learned a new command for the designer.

            Thank you so much, my alignment issues are now a thing of the past!

            mrjjM 1 Reply Last reply
            0
            • O Omni_Philm

              @mrjj

              Aw man, you have got to be kidding me!!!! It was there the entire time!!! I feel silly now!

              Oh well, I learned a new command for the designer.

              Thank you so much, my alignment issues are now a thing of the past!

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

              @Omni_Philm
              Dont worry, its pretty normal.
              I think i used Designer for maybe 8 months before i discovered that i could actually insert splitter in Designer :)
              alt text
              The option is only shown if u have selected 2+ widgets.

              Or the secret Refactor menu in Creator code editor.
              alt text
              Allowing very easy to insert a virtual function from the base class by simply selecting in the list.
              Or that it can add the function body to the cpp. (or reverse)
              Or the odd little light bulb
              alt text
              when i changed the function parameters, which turned out to be a super feature
              alt text
              that allows you to have Creator change the .h file or reverse so they match. (again)
              And finally after right click alot , i found out that alt+enter triggers the menu
              when you are in the right context.
              And a few more hidden gems :)

              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