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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:12:38+00:00 2026-05-23T22:12:38+00:00

I am new to Qt and am having difficulties with scrollbars in QWidgets. I

  • 0

I am new to Qt and am having difficulties with scrollbars in QWidgets.
I have a layout in a widget and the layout contains a QMenuBar. The Scroll area is associated with the widget. The scroll works fine but when the user scrolls down the Menubar goes out of sight. Is there any way to keep the Menu at the top?

Any help would be appreciated.

Thanks.

Hi @utdemir,

Thanks for quick reply.
Here is the snippit of the code with your suggestion of using QMainWindow. It produced the same results.

MyWidget::MyWidget(QMainWindow *parent)
: QMainWindow(parent)
{
    main = new QWidget;       //Widget that contains the layout
    CreateMenu();
    scrollArea  = new QScrollArea;
    layout = new QVBoxLayout();

    //layout->setMenuBar(menuBar);
    this->setMenuBar(menuBar);
    this->resize(500,500);
    main->setLayout(layout);
    this->setCentralWidget(main);
    scrollArea->setWidget(this);
    scrollArea->setWidgetResizable(true);

    scrollArea->show();

    this->show();
}
  • 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-05-23T22:12:40+00:00Added an answer on May 23, 2026 at 10:12 pm

    Figured out the solution to the problem.
    Created a QMainWindow which contains the menu bar. Added a QWidget which contains the layout. The scroll area is associated to the QWidget. The central widget of the mainwindow is set to be the scroll area.

    main->setLayout(layout);
    this->setCentralWidget(scrollArea);
    scrollArea->setWidget(main);
    scrollArea->setWidgetResizable(true);
    scrollArea->show();
    this->show();
    

    Thank you for your help @utdemir

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

Sidebar

Related Questions

I am new learner to jquery/js. I am having difficulties making a scroll tab
i'm having difficulties implementing custom widget rendering in a QListView . I currently have
I have seen new computers having two processors on same motherboard . How can
I am having a new little problem; I have a little pointer called: int
I'm having difficulties reading an app.config using the ConfigurationManager. I have a custom section,
I'm having difficulties getting an association to work with simple_form . I have the
I am new to the C objective and I'm having lots of difficulties. Hope
I'm quite to new to SQL Server, and I'm having difficulties creating a data
I'm having some difficulties getting my head around Rails' general application layout. Basically, I
I have the following setup in my application and I'm having some difficulties passing

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.