Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ QMainWindow中央Widget边框_C++_Windows_Qt_Qt4 - Fatal编程技术网

C++ QMainWindow中央Widget边框

C++ QMainWindow中央Widget边框,c++,windows,qt,qt4,C++,Windows,Qt,Qt4,我有一个QMainWindow,其中心小部件已设置为QGraphicsView,用于查看黑色场景(用于测试)。注意,在下面的代码中,我使用了从QGraphicsView派生的类,称为CQtGlView,它只重新实现resizeEvent函数 无论是否直接添加视图 CQtMainWindow::CQtMainWindow() { m_glView = new CQtGlView(); setCentralWidget(m_glView); } 或者将其粘贴在虚拟小部件中边距为0的布局中

我有一个QMainWindow,其中心小部件已设置为QGraphicsView,用于查看黑色场景(用于测试)。注意,在下面的代码中,我使用了从QGraphicsView派生的类,称为CQtGlView,它只重新实现resizeEvent函数

无论是否直接添加视图

CQtMainWindow::CQtMainWindow() {
  m_glView = new CQtGlView();
  setCentralWidget(m_glView);
}
或者将其粘贴在虚拟小部件中边距为0的布局中

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);
}
我在小部件周围得到了一个不需要的灰色边框

下面的屏幕截图说明了问题,在我的场景和windows aero边框之间可见

如果我的应用程序不允许切换到全屏,这将不会是一个问题。当屏幕的其余部分变黑时,边框非常明显

该区域可能表示中心小部件外部的DockWidgetAreas


除了不使用QMainWindow之外,我还能做些什么来解决这个问题吗?(由于我使用了菜单栏、工具栏和状态栏,这是不可取的。)

事实证明,QGraphicsView源自QFrame,我假设它只是一个QWidget

这个问题的解决方案是调用(QFrame::NoFrame);在我的QGraphicsView子类的构造函数中。或者如果它不是一个子类


m_glView->setFrameStyle(QFrame::NoFrame)

您在QGraphicsView上尝试过setFrameShape(QFrame::NoFrame)吗