wysota,
I hope it is my fault, as I couldn't figure out how to fix this problem.
Below are the files for the case. When commenting out the below line in QGuiMainScreen.cpp, the scrollbars disappears:
this->setMenuBar ( menuBar );
this->setMenuBar ( menuBar );
To copy to clipboard, switch view to plain text mode
QGuiMainScreen.h
#include <QMainWindow>
#include <QMenuBar>
#include <QGraphicsView>
{
public:
QGuiMainScreen();
virtual void show();
private:
};
#include <QMainWindow>
#include <QMenuBar>
#include <QGraphicsView>
class QGuiMainScreen: public QMainWindow
{
public:
QGuiMainScreen();
virtual void show();
private:
QGraphicsView* m_gv;
};
To copy to clipboard, switch view to plain text mode
QGuiMainScreen.cpp
#include "QGuiMainScreen.h"
#include <QLayout>
#include <QGLWidget>
{
this->resize ( 1024, 768 );
centralwidget
= new QWidget ( this );
this->setCentralWidget ( centralwidget );
menuBar
->setGeometry
( QRect ( 0,
0,
1024,
30 ) );
menuSystem
= new QMenu ( menuBar
);
menuSystem->setTitle ( "System" );
menuBar->addAction ( menuSystem->menuAction() );
this->setMenuBar ( menuBar );
outerLayout->setSpacing ( 0 );
outerLayout->setMargin ( 0 );
outerLayout->insertWidget ( 0, m_gv, 1 );
}
void QGuiMainScreen::show()
{
qint32 sceneWidth = m_gv->viewport()->width();
qint32 sceneHeight = m_gv->viewport()->height();
m_gv->scene()->setSceneRect ( -sceneWidth / 2, -sceneHeight / 2, sceneWidth, sceneHeight );
}
#include "QGuiMainScreen.h"
#include <QLayout>
#include <QGLWidget>
QGuiMainScreen::QGuiMainScreen() : QMainWindow()
{
QWidget *centralwidget;
QHBoxLayout *outerLayout;
QMenuBar *menuBar;
QMenu *menuSystem;
this->resize ( 1024, 768 );
centralwidget = new QWidget ( this );
this->setCentralWidget ( centralwidget );
menuBar = new QMenuBar ( this );
menuBar->setGeometry ( QRect ( 0, 0, 1024, 30 ) );
menuSystem = new QMenu ( menuBar );
menuSystem->setTitle ( "System" );
menuBar->addAction ( menuSystem->menuAction() );
this->setMenuBar ( menuBar );
outerLayout = new QHBoxLayout ( centralwidget );
outerLayout->setSpacing ( 0 );
outerLayout->setMargin ( 0 );
m_gv = new QGraphicsView ( this );
m_gv->setScene ( new QGraphicsScene() );
outerLayout->insertWidget ( 0, m_gv, 1 );
}
void QGuiMainScreen::show()
{
QMainWindow::show();
m_gv->setViewport ( new QGLWidget() );
qint32 sceneWidth = m_gv->viewport()->width();
qint32 sceneHeight = m_gv->viewport()->height();
m_gv->scene()->setSceneRect ( -sceneWidth / 2, -sceneHeight / 2, sceneWidth, sceneHeight );
}
To copy to clipboard, switch view to plain text mode
main.cpp
#include <QApplication>
#include "QGuiMainScreen.h"
int main ( int argc, char *argv[] )
{
QGuiMainScreen myWnd;
myWnd.show();
return app.exec();
}
#include <QApplication>
#include "QGuiMainScreen.h"
int main ( int argc, char *argv[] )
{
QApplication app ( argc, argv );
QGuiMainScreen myWnd;
myWnd.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
pro file
TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
QT += opengl
# Input
HEADERS += QGuiMainScreen.h
SOURCES += main.cpp QGuiMainScreen.cpp
TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
QT += opengl
# Input
HEADERS += QGuiMainScreen.h
SOURCES += main.cpp QGuiMainScreen.cpp
To copy to clipboard, switch view to plain text mode
Sami
Bookmarks