QDialog remove title line
The web is flooded with similar questions, but for everyone I've seen, nothing seems to work to solve the problem.
In my QT-C ++ application, I have a mainwindow form with some functionality, there is a QPushButton that when clicked opens a QDialog. All of the functionality in forms works fine now, but I want the final application without any top title bar. those. Close / Collapse / Enlarge button.
In my main.cpp, I did -
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
w.show();
return a.exec();
}
as a result, the main turn became -
In the dialog.cpp window , I have set -
Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{
ui->setupUi(this);
//QDialog Dialog(0, Qt::CustomizeWindowHint|Qt::WindowTitleHint); --- used this also; no use
QDialog Dialog(0, Qt::FramelessWindowHint | Qt::Dialog);
But the QDialog title bar remains, it looks like
Where am I wrong ??? any ideas on how to remove the close button and title bar ???
source to share
Solved it with the help of a friend, posting an answer for help for someone who needs it ---
in mainwindow.cpp, when the Fetch button is clicked, the qdialog opens, I set the properties there;
void MainWindow::on_pushButton_2_clicked()
{
Dialog dialog;
dialog.setModal(true);
dialog.setWindowFlags(Qt::FramelessWindowHint);
dialog.exec();
}
This did the trick -
and the dialogue -
source to share
I needed to do the same as this question for dialogs, but I needed a border in a dialog without a window. The solution was pretty simple. Just set the dialog flags in Qt :: CustomizeWindowHint:
dialog.setWindowFlags(Qt::CustomizeWindowHint);
You can also use this with specific flags to further customize the appearance of the window as stated in the documentation.
source to share