Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9132263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:16:55+00:00 2026-06-17T08:16:55+00:00

The question says it all. I have a 5×3 grid. It looks like this

  • 0

The question says it all.

I have a 5×3 grid.

It looks like this

row 0:  buttonA--buttonA--buttonA   nothing   buttonB--buttonB--buttonB

row 1:  empty row

row 2:  buttonC  nothing  buttonD   nothing   buttonE  nothing  buttonF     

In the spaces where there is nothing in the whole column or row the minimumRowHeight and all of those settings would work. Right?

Well. The button A and button B (and the rest), never get centered over those 3 cells they share. NEVER. doesn´t matter what i write on the parameters for the layout.

I erased the code because it finally got it using a Vertical Layout, and inside, two horizontal layouts. Those get centered that way. But i would like to position them better.

What doesn’t work is when adding a widget, using:

addWidget(widget, 0,0, 2, 0, Qt::AlignHCenter);

not even AlignCenter works.

How to make it centered or aligned to the right?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T08:16:56+00:00Added an answer on June 17, 2026 at 8:16 am

    The syntax of QGridLayout::addWidget() is like this:

    void QGridLayout::addWidget ( QWidget * widget, int fromRow, int fromColumn, int rowSpan, int columnSpan, Qt::Alignment alignment = 0 )

    with the description:

    This version adds the given widget to the cell grid, spanning multiple rows/columns. The cell will start at fromRow, fromColumn spanning rowSpan rows and columnSpan columns.

    This means your line

    addWidget( widget, 0, 0, 2, 0, Qt::AlignHCenter ); 
    

    has fromRow = 0, fromColumn = 0, rowSpan = 2 and columnSpan = 0. This means it starts from row 0 and spans over two rows, i.e. it will be in row 0 and 1 (Note: Two rows in total, not two additional rows). Also it starts from column 0 with a span of 0 which I think means the column span is ignored.

    So what you really want should be:

    addWidget( widget, 0, 0, 0, 3, Qt::AlignCenter );
    

    You might have to experiment with the alignment a bit.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Question says it all. If I have this for a 96-bit field: uint32_t flags[3];
The question pretty much says it all. I have a joomla website and I
Question says it all. I'm just having trouble figuring this out. What i'm trying
Question says it all. I have two accounts on two separate hosted fogbugz-on-demand. One
The question says it all really. I'm hoping that I don't have to write
i think the question says it all, but I have an application that uses
The question pretty much says it all. I have an app with an older
well the question says it all I have some contour and I want to
Question says it all. Customer needs to register a DLL, doesn't have Visual Studio
Question says all really... I have table in a MySQL database which has a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.