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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:58:50+00:00 2026-06-12T04:58:50+00:00

QGridLayout *layout = new QGridLayout (); centralWidget->setLayout (layout); layout->addWidget (refresh, 0, 0); layout->addWidget (zoomIn,

  • 0
    QGridLayout *layout = new QGridLayout ();
    centralWidget->setLayout (layout);
    layout->addWidget (refresh, 0, 0);
    layout->addWidget (zoomIn, 1, 0);
    layout->addWidget (zoomOut, 1, 1);
    layout->addWidget (panLeft, 2, 0);
    layout->addWidget (panRight, 2, 1);
    layout->addWidget (panTop, 3, 0);
    layout->addWidget (panBottom, 3, 1);
    layout->addWidget (findInfo, 4, 0);
    layout->addWidget (textEdit, 5, 0);

    window->setCentralWidget (centralWidget);

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-12T04:58:51+00:00Added an answer on June 12, 2026 at 4:58 am

    I think we need some more context. I took your code and wrapped it into the following complete sample application:

    #include <QGridLayout>
    #include <QPushButton>
    #include <QTextEdit>
    #include <QApplication>
    #include <QMainWindow>
    
    int main(int argc, char ** argv) {
        QApplication app( argc, argv );
        QMainWindow win;
    
        QWidget* centralWidget = new QWidget(&win);
        QPushButton* refresh = new QPushButton("Start R");
        QPushButton* zoomIn = new QPushButton("Zoom in");
        QPushButton* zoomOut = new QPushButton("Zoom out");
        QPushButton* panLeft = new QPushButton("Left");
        QPushButton* panRight = new QPushButton("Right");
        QPushButton* panTop = new QPushButton("Top");
        QPushButton* panBottom = new QPushButton("Bottom");
        QPushButton* findInfo = new QPushButton("Find Info");
        QTextEdit* textEdit = new QTextEdit("Vehicle Info. Will be shown here.");
    
    ///////////////////////////// Your Code
        QGridLayout *layout = new QGridLayout ();
        centralWidget->setLayout (layout);
        layout->addWidget (refresh, 0, 0);
        layout->addWidget (zoomIn, 1, 0);
        layout->addWidget (zoomOut, 1, 1);
        layout->addWidget (panLeft, 2, 0);
        layout->addWidget (panRight, 2, 1);
        layout->addWidget (panTop, 3, 0);
        layout->addWidget (panBottom, 3, 1);
        layout->addWidget (findInfo, 4, 0);
        layout->addWidget (textEdit, 5, 0);
    
        window->setCentralWidget (centralWidget);
    ///////////////////////////// End your code
    
        win.show();
        app.connect( &app, SIGNAL( lastWindowClosed() ), &app, SLOT( quit() ) );
        return app.exec();
    }
    

    This results in the following layout:

    Screenshot

    It looks like you have added some size constraints on the buttons, since they all have the same size in your screenshot (besides the Start button).

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

Sidebar

Related Questions

I have two QSliders placed in GridLayout like this: layout = new GridLayout(); layout->addWidget(slider_horizontal,
I have a problem with a QGridLayout. One row of my layout contains an
I'm quite new to creating layout using SWT. This is what I have to
I'm trying to layout a window (all in code) with a QGridLayout . I
I have a button followed by a QGridLayout full of widgets. I want to
How can I change behavior of how items are selected in QGridLayout by cursor
How do we show the gridline in GridLayout? in Java? JPanel panel = new
I'm new in Java. I'm making Mines. I'm using GridLayout with paramteres (x_length, y_length).
I want to have a 3x3 grid layout structured like this: _ _ _
Problem: My program layout is fine, as below before I add JToolbar to BorderLayout.PAGE_START

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.