Frameless window, showMinimized() does not work
-
MacOS version: 10.13.2
Qt: 5.9.3 and 5.10Window flags: setWindowFlag(Qt::FramelessWindowHint);
The showMinimized() function dos not work.
I added cocoa implements,
NSView* view = (NSView*)this->winId(); if (0 == view) {return;} NSWindow *window = view.window; if (0 == window) {return;} [window performMiniaturize:nil];
It does not work either.
-
Hi,
Please provide a complete minimal compilable example to reproduce the behavior.
-
It is very simple.
Just create an simple project via wizard, drag a pushbutton to the centerwidget.
and then setWindowFlag(Qt::FramelessWindowHint);, then connect the signal clicked of the button to slot showMinimized() of mainwindow.If you wan to implement cocoa code shown in my first post, you can add new objc++ source file, and implement the slot function in this objc++ file.
-
I know it’s not complicated hence my query so we are all working with the same code base.
-
@SGaist
mainwindow.hh#ifndef MAINWINDOW_HH #define MAINWINDOW_HH #include <QMainWindow> namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); private slots: void on_pushButton_clicked(); private: Ui::MainWindow *ui; }; #endif // MAINWINDOW_HH
#include "mainwindow.hh" #include "ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); setWindowFlag(Qt::FramelessWindowHint); } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_pushButton_clicked() { showMinimized(); }
mainwindow.ui
<?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>MainWindow</class> <widget class="QMainWindow" name="MainWindow"> <property name="enabled"> <bool>true</bool> </property> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>400</width> <height>300</height> </rect> </property> <property name="windowTitle"> <string>MainWindow</string> </property> <widget class="QWidget" name="centralWidget"> <layout class="QHBoxLayout" name="horizontalLayout"> <item> <widget class="QPushButton" name="pushButton"> <property name="text"> <string>PushButton</string> </property> </widget> </item> </layout> </widget> <widget class="QMenuBar" name="menuBar"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>400</width> <height>22</height> </rect> </property> </widget> <widget class="QToolBar" name="mainToolBar"> <attribute name="toolBarArea"> <enum>TopToolBarArea</enum> </attribute> <attribute name="toolBarBreak"> <bool>false</bool> </attribute> </widget> <widget class="QStatusBar" name="statusBar"/> </widget> <layoutdefault spacing="6" margin="11"/> <resources/> <connections/> </ui>
#include "mainwindow.hh" #include <QApplication> #include <QWidget> int main(int argc, char *argv[]) { QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); QApplication a(argc, argv); MainWindow w; w.show(); return a.exec(); }
-
I'm not yet on 10.13.2 however I can't reproduce that on my 10.12.6, it works as expected.
-
Might be related to QTBUG-65265