How we can disable the close [X] button in the top right corner of GUI?
-
-
@Gojir4 @Chrisw01
where should I add this line exectly?
setWindowsFlags(Qt::WindowCloseButtonHint, false);#include "mainwindow.h" #include "ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_pushButton_clicked() { ui->textEdit->setText("this is for test"); }
-
@Mijaz Please read again what @Gojir4 wrote:
"Add setWindowsFlags(Qt::WindowCloseButtonHint, false); in your widget's constructor"https://doc.qt.io/qt-5/qtwidgets-widgets-windowflags-example.html
-
@Gojir4
Hi,
I am using qt4.8.7.
your suggested command not working.#include "mainwindow.h" #include "ui_mainwindow.h" #include <QDebug> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); setWindowFlags(Qt::WindowCloseButtonHint, false); timerId = startTimer(1000); } MainWindow::~MainWindow() { killTimer(timerId); delete ui; } void MainWindow::timerEvent(QTimerEvent *event) { qDebug() << "Update..."; ui->lineEdit->setText("test "); }
-
@Mijaz Please read documentation: https://doc.qt.io/qt-5/qwidget.html#windowFlags-prop
setWindowFlags(windowFlags() & ~Qt::WindowCloseButtonHint);
-
@Mijaz said in
button in the top right corner of GUI?:I am using qt4.8.7.
Important information, that one should state in the opening post.
besides that, looking into the Qt4 Documentation shows the following:
https://doc.qt.io/archives/qt-4.8/qwidget.html#windowFlags-prop
with an actual example on how top use it:
https://doc.qt.io/archives/qt-4.8/qt-widgets-windowflags-example.html->
setWindowFlags(windowFlags() & ~Qt::WindowCloseButtonHint);
-
@Mijaz said in
button in the top right corner of GUI?:this->setWindowFlags(Qt::WindowMaximizeButtonHint);
Keep in mind that this way you disable all other flags. But as long as this is fine for you you can do it this way.
-
@Mijaz change the window manager on the board...
Here a guide, on how to do it on GNOME, should be similar for all Linux flavors
https://linuxcommando.blogspot.com/2014/07/how-to-change-window-manager-for-gnome.html