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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:53:48+00:00 2026-06-09T19:53:48+00:00

I have a QMainWindow whose central widget has been set to a QGraphicsView viewing

  • 0

I have a QMainWindow whose central widget has been set to a QGraphicsView viewing a black scene (for test purposes). Note that in the code below, I use my class derived from QGraphicsView, called CQtGlView, which reimplements only the resizeEvent function.

Regardless of whether I add the view directly,

CQtMainWindow::CQtMainWindow() {
  m_glView = new CQtGlView();
  setCentralWidget(m_glView);
}

or stick it in a layout with margins of 0 in a dummy widget,

CQtMainWindow::CQtMainWindow() {
  m_glView = new CQtGlView();

  QWidget* dummy = new QWidget();
  QHBoxLayout* l = new QHBoxLayout();
  l->setContentsMargins(0,0,0,0);
  l->addWidget(m_glView);
  dummy->setLayout(l);

  setCentralWidget(dummy);
}

I get an unwanted grey border around the widget.

The screenshot below illustrates the problem, visible between my scene and the windows aero border.

Border around centralWidget

This would not be a problem if my application did not allow switching to full screen. The border is very obvious once the rest of the screen is black.

It’s possible this area represents the DockWidgetAreas around the outside of the central widget.

Is there anything I can do to solve this other than not use QMainWindow? (Undesirable due to my use of menuBar, tool bars, and statusBar.)

  • 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-09T19:53:50+00:00Added an answer on June 9, 2026 at 7:53 pm

    It turns out that QGraphicsView derives from QFrame, where I assumed it was only a QWidget.

    The solution to this problem was to call setFrameStyle(QFrame::NoFrame); in the constructor of my QGraphicsView subclass. Or if it was not a subclass,

    m_glView->setFrameStyle(QFrame::NoFrame);

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

Sidebar

Related Questions

I have a widget class subclass of QMainWindow, and it has a central widget(QWidget),
i have a QMainWindow. It has this parameters: this->setWindowFlags(Qt::Tool); this->setFocusPolicy(Qt::StrongFocus); this->setAttribute(Qt::WA_QuitOnClose,true); After showEvent calles
I have a QMainWindow which spawns a few wizards. The QMainWindow has a QFrame
I basically have a QMainWindow, and a Dialog window whose constructor is shown below;
is there away to set global mouseReleaseEvent? what i mean is i have QMainWindow
Using the QMainWindow I have added 3 DockWidgets and set centralWidget to 0, so
I have a small problem with adding widget to QMainWindow. When i do it
I have a QMainWindow that has a QWidget . The QWidget appears, and has
I have a PySide app which has an icon for the MainWindow (a QMainWindow
I have a TextBox control within a StackPanel whose Orientation is set to Horizontal

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.