Raise QWidget to QMainWindow or add QMainWindow to QWidget from Qt Designer

My problem:

I want to customize the way I work title barand am looking for my application.

My idea:

I created a new QWidgetform in Qt Designerand added to it QWidget. I added the following constructor to the constructor:

setAttribute(Qt::WA_TranslucentBackground);
setWindowFlags(Qt::FramelessWindowHint);

QGraphicsDropShadowEffect* effect = new QGraphicsDropShadowEffect();
effect->setBlurRadius(20);
effect->setXOffset(0);
effect->setYOffset(0);
setGraphicsEffect(effect);

which makes the external widget transparent and adds a shadow to my internal widget. From this, I can create my own title bar widget, which I can implement, but I want.

This is the result:

enter image description here

My problem

I want to make it suitable for use by the designer as the main window, and QWidgetdoes not allow to add FROM DESIGNER tool bars, menu barand status bar.

QMainWindow QWidget ( ( )). , :

QMainWindow *centralwidget = new QMainWindow();
centralwidget->setStyleSheet("background-color: lightgray;");
centralwidget->setGeometry(0, 0, 50, 20);
centralwidget->setWindowFlags(Qt::Widget);
this->layout()->addWidget(centralwidget);

QMenuBar *menuBar = new QMenuBar(centralwidget);
menuBar->addAction("Action");

QStatusBar *statusBar = new QStatusBar;
statusBar->showMessage("Status bar here");

centralwidget->addToolBar("tool bar");
centralwidget->setMenuBar(menuBar);
centralwidget->setStatusBar(statusBar);

:

enter image description here

:

Qt Designer? QWidget QMainWindow? ... Qt Designer, - , . QCustomMainWindow Qt Creator , QWidget QMainWindow.

, !

+4
1

, : Qt4: QMainWindow QWidget/QMainWindow

:

QMainWindow, . QMainWindow QWidget. , . ui->setup().

QMainWindow

Project selection dialog

Form Selection Dialog

, mainwindow.cpp

http://qt-project.org/doc/qt-5/qt.html#WindowType-enum

this->setWindowFlags(Qt::Widget);

QWidget. , , . . Qt:: Window Qt:: SubWindow.

// or if you want to apply more than one you, "or" it together, like so:
this->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::Tool);

, .

, , .

http://qt-project.org/doc/qt-5/qt.html#WidgetAttribute-enum

Qt

:

http://qt-project.org/doc/qt-5/stylesheet-reference.html

this->setStyleSheet("background: #000000;");

Qt Designer

, , Qt Designer, Qt Designer .

http://qt-project.org/doc/qt-4.8/designer-using-custom-widgets.html

http://qt-project.org/doc/qt-4.8/designer-creating-custom-widgets.html

QMdiArea QMdiWindow

, QMainWindow, - QMdiSubWindow

http://qt-project.org/doc/qt-5/QMdiSubWindow.html

+2

All Articles