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. QGridelayout, align with missing column?

QGridelayout, align with missing column?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 386 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.
  • Jonathan LevanonJ Offline
    Jonathan LevanonJ Offline
    Jonathan Levanon
    wrote on last edited by
    #1

    Hi,

    I want to create a really simple button UI, 2 on the top row and one on the bottom row. Is there anyway to use one widget to contain them all, and set a grid layout for that?
    current code -

    ctrlPanelLay.addWidget(_play, 0,0);
    ctrlPanelLay.addWidget(_stop, 0,1);
    ctrlPanelLay.addWidget(exitButton, 1,0);
    

    When using the grid layout, I get
    1_1556614308237_Screenshot from 2019-04-30 11-49-16.png
    But what I want is
    0_1556614308236_Screenshot from 2019-04-30 11-49-16_2.png

    Is this some alignment issue?

    Gojir4G 1 Reply Last reply
    0
    • Jonathan LevanonJ Jonathan Levanon

      Hi,

      I want to create a really simple button UI, 2 on the top row and one on the bottom row. Is there anyway to use one widget to contain them all, and set a grid layout for that?
      current code -

      ctrlPanelLay.addWidget(_play, 0,0);
      ctrlPanelLay.addWidget(_stop, 0,1);
      ctrlPanelLay.addWidget(exitButton, 1,0);
      

      When using the grid layout, I get
      1_1556614308237_Screenshot from 2019-04-30 11-49-16.png
      But what I want is
      0_1556614308236_Screenshot from 2019-04-30 11-49-16_2.png

      Is this some alignment issue?

      Gojir4G Offline
      Gojir4G Offline
      Gojir4
      wrote on last edited by
      #2

      @Jonathan-Levanon Hi,

      You need to set the columnSpan to 2 for you last element, and then set alignment to horizontal center I guess.

      trlPanelLay.addWidget(exitButton, 1,0, 1, 2, Qt::AlignHCenter);
      
      Jonathan LevanonJ 1 Reply Last reply
      3
      • Gojir4G Gojir4

        @Jonathan-Levanon Hi,

        You need to set the columnSpan to 2 for you last element, and then set alignment to horizontal center I guess.

        trlPanelLay.addWidget(exitButton, 1,0, 1, 2, Qt::AlignHCenter);
        
        Jonathan LevanonJ Offline
        Jonathan LevanonJ Offline
        Jonathan Levanon
        wrote on last edited by
        #3

        @Gojir4 Like a charm, thanks!

        1 Reply Last reply
        0

        • Login

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