How can the toolbar be implemented in the top bar, like, for example, Tiled
has it done?
Normally, the toolbar looks like the follows:
Example code how it is currently:
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = nullptr) {
auto *tbar = new QToolBar();
tbar->addWidget(new QPushButton("Push Me"));
this->addToolBar(tbar);
}
};
If you are still using Qt 4.x, you can just use the setUnifiedTitleAndToolBarOnMac(bool set)
function that is included in QMainWindow:
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = nullptr) {
auto *tbar = new QToolBar();
tbar->addWidget(new QPushButton("Push Me"));
this->addToolBar(tbar);
this->setUnifiedTitleAndToolBarOnMac(true); // activate Mac-style toolbar
}
};
See also: https://qt-project.org/doc/qt-4.8/qmainwindow.html#unifiedTitleAndToolBarOnMac-prop
If you are using Qt5, check out QtMacExtras (https://github.com/qt/qtmacextras)
You can give your QToolBar a native Mac look and feel using QtMacExtras::setNativeToolBar
If you subclass QMainWindow and/or QToolBar and change the kind of frame they load/have, you may be able to get the effect you want.
http://qt-project.org/doc/qt-4.8/qframe.html#details
http://qt-project.org/doc/qt-4.8/stylesheet-examples.html#customizing-qframe
http://qt-project.org/doc/qt-4.8/stylesheet-customizing.html#the-box-model
Another way to maybe achieve this result, but is kind of hacky, you could put another frameless widget of the right color over the part of the frames that are showing. Using Qt:Tool
and Qt::WindowStaysOnTopHint
and Qt::FramelessWindowHint
, you should be able to get your coverup widget to hide the joint.
Hope that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With