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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:00:25+00:00 2026-06-10T10:00:25+00:00

I have an application with a QMainWindow that should ideally have a QGLWidget centered

  • 0

I have an application with a QMainWindow that should ideally have a QGLWidget centered on it, with spaces left around the outside for toolbars and other top/side widgets.

Unfortunately, no matter what size or geometry the QGLWidget is set to, it appears enormous and takes up the entire main window!

Basically, the setup is as follows: CreateWindow() is called in main(), which constructs the main window and calls a function Init(), which constructs the GLWidget. So, within Init(), which is a member of my adapted main window class, I essentially have:

GLScene = new MyQGLWidget(this);  
setCentralWidget(GLScene); 

Now, to make the GLScene conform to its desired size and position, I first tried setting its geometry within the GLWidget (a.k.a. my class derived directly from GLWidget) constructor:

MyQGLWidget::MyQGLWidget(QWidget* parent){
    ....
    setGeometry(210, 40, 600, 400);  //the main window is of course bigger and should fit this nicely 
    ....
}

This, however, didn’t work at all and still made it take up the entire main window. Instead, I tried putting the setGeometry call into Init(). I tried it both right before and right after setCentralWidget(); neither option worked. Nor did flat-out removing the setCentralWidget call (in fact, this made the GLWidget disappear).

Since this clearly isn’t working properly, what is the correct way to scale the GLWidget? Or is it just a matter of how things are ordered that I need to look into more deeply?

  • 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-10T10:00:26+00:00Added an answer on June 10, 2026 at 10:00 am

    You need to add a layout to it. I have exactly the same thing ( a widget derived from QGLWidget) whose parent calls the resize function. This solved all my issues and made it to where I can change its size at runtime.

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

Sidebar

Related Questions

I have a netbeans Java application that should display a JFrame (class StartUpWindow extends
I have a Qt application that uses a QMainWindow -derived class for the main
I have application that makes different queries with different results so the caching in
I have application that is connecting to the DB and if I enter incorrect
I have a Silverlight application that consists of a MainWindow and several classes which
I'm developing a python application and have a question regarding coding it so that
I have an IPhone application that I want to attempt login and do some
I currently have an application that does the the following: S: Loads a view
I have an application with the following UI forms deriving from QMainWindow LoginWindow TasksWindow
I have a Qt application that contains a QTreeWidget. I want to replace one

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.