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 8727967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:32:12+00:00 2026-06-13T08:32:12+00:00

Here is how to draw a button that spans 2 columns: #include <QtGui> int

  • 0

Here is how to draw a button that spans 2 columns:

#include <QtGui>

int main(int argv, char **args)
{
    QApplication app(argv, args);

    QPushButton *foo = new QPushButton("foo");
    QPushButton *bar = new QPushButton("bar");
    QPushButton *baz = new QPushButton("baz");

    QGridLayout *layout = new QGridLayout();
    layout->addWidget(foo, 0, 0);
    layout->addWidget(bar, 0, 1);
    layout->addWidget(baz, 1, 0, 1, 2); // span 2 columns

    QWidget window;
    window.setLayout(layout);
    window.setWindowTitle("test");
    window.show();

    return app.exec();
}

Running the code gives me:

enter image description here

If I change the layout in order to get a button, baz, that spans 2 rows I fail:

layout->addWidget(foo, 0, 0);
layout->addWidget(bar, 1, 0);
layout->addWidget(baz, 0, 1, 2, 1); // (try to) span 2 rows

Here is what I get:

enter image description here

  • 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-13T08:32:13+00:00Added an answer on June 13, 2026 at 8:32 am

    Your layout is fine, the baz button is spanning two rows. The problem is that it doesn’t use all the available space. You have to change the vertical resize policy of your button from Fixed to MinimumExpanding.

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

Sidebar

Related Questions

int main(int argc,char * argv[]){ srand(time(NULL)); glutInit(&argc,argv); // Setup GLUT glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB
I'm trying to draw a button with an image as background. Here's my xml:
Ok, here's the condensed form. I have three main tables to draw data from:
I don't understand what I'm doing wrong here: public void Draw(GameTime gameTime) // in
Here is the code I use to draw: - (void) drawSomething { CGContextRef context
Say I want to draw a Ball in the scene and here are two
I'd like to draw some statistics charts using QT4.7 , here are some examples:
I need to draw a counter onto an OpenGL view. Here is my source
I am trying to draw a red rectangle on my HTML5 canvas. Here is
In my SVG, which you can see on pastebin here , I draw two

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.