Solved Can we remove Dialog or Mainwindow written on the top of Application output.
-
Can we remove the dialog/Black menu line written on the top of the output screen
-
Hi
Do you mean its caption ? (where it says dialog)
you can get a frameless window by
setWindowFlag(Qt::FramelessWindowHint ,true); -
@mrjj
Thanku for the response.It's showing this error
/home/ashutosh/Ashu_QT/build-Main_Demo-Desktop-Debug/ui_menu.h:45: error: 'class QFrame' has no member named 'setWindowFlag'
frame->setWindowFlag(Qt::FramelessWindowHint,true);
^
////////////////////////////////////////////////////////////////////////////////////////////////////////////frame->setWindowFlags(Qt::FramelessWindowHint);
Even i tried this, it's compiling but not effecting the window frame.
-
@Ashutosh_Sachdeva
What Qt version are you using ?Mine accepts
ui->frame->setWindowFlag(Qt::FramelessWindowHint,true);
frame being QFrame.But why do you set it on your Qframe. is that window a QFrame ?
It really looks like QDialog.
You have to use on the top window. not something inside.So are we talking the caption ?
You did not answer that. -
@mrjj
i'm using QT 5.13.1Yes i have taken dialog box without buttons and i want o remove that dialog caption and that black line
-
Ok so you just call
setWindowFlag(Qt::FramelessWindowHint,true);
in dialogs constructor and it should show with no decorations ( Caption and borders) -
@mrjj
Sir, Tried but its throwing the below error/home/ashutosh/Ashu_QT/Main_Demo/menu.cpp:10: error: 'class QFrame' has no member named 'setWindowFlag'
ui->frame->setWindowFlag(Qt::FramelessWindowHint ,true);
^ -
Hi,
Might be a silly question but are you sure about the Qt version you are using ? This method was added in Qt 5.9.
-
@SGaist yeah sir i.m sure. Its 5.13.1
-
@Ashutosh_Sachdeva said in Can we remove Dialog or Mainwindow written on the top of Application output.:
ui->frame->setWindowFlag(Qt::FramelessWindowHint ,true);
Please read again what @mrjj suggested: he suggested to call setWindowFlag(Qt::FramelessWindowHint,true); without ui->frame-> in front of it...
-
I think my fellow poster's may lead you in the wrong direction.
From what I understand, the function setWindowTitle
https://doc.qt.io/qt-5/qwidget.html#windowTitle-prop
is what you're looking for.By default the Window Title is the name of your app, and for dialogs its the class name (I think).
Just use the setWindowTitle function to change it to what ever you like, even an empty string, to not show anything. -
I think my fellow poster's may lead you in the wrong direction.
Nah, I don't think so. The OP wrote:
Can we remove the dialog/Black menu line written on the top of the output screen
Yes i have taken dialog box without buttons and i want o remove that dialog caption and that black lineI think the "black line" does mean he wants the whole of the dialog title (including the button furniture at top-left, whether he has realized that or not) removed, not just the title string itself.
So he needs to try
dialog->setWindowFlag(Qt::FramelessWindowHint, true);
, orthis->setWindowFlag(Qt::FramelessWindowHint, true);
if he is insideQDialog
-derived code. -
@JonB oh,
I only read the title of this thread ...Can we remove Dialog or Mainwindow written on the top of Application output.
-
@J-Hilk Always pays to read the body of threads too ;-)
-
Yeah tried but its throwing below mentioned error
/home/ashutosh/Ashu_QT/Main_Demo/menu.cpp:10: error: 'setWindowFlag' was not declared in this scope
setWindowFlag(Qt::FramelessWindowHint,true);//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
i have tried with this "setWindowFlags(Qt::FramelessWindowHint);" as well and thus function is closing the whole window. -
@Ashutosh_Sachdeva Please show your code, I do not want to guess...
-
Sorry, may be i'm doing something wrong but i'm not able to find anyfunction named "Setwindoflag" (this can be stupid but i don't know why this is happening) . And i'f i'm using "setwindowflags" this function is closing the complete page.
-
This post is deleted! -
@Ashutosh_Sachdeva said in Can we remove Dialog or Mainwindow written on the top of Application output.:
And i'f i'm using "setwindowflags" this function is closing the complete page
If using setWindowFlags you need to keep all other flags:
setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
-
@Ashutosh_Sachdeva said in Can we remove Dialog or Mainwindow written on the top of Application output.:
@JonB
Sorry, may be i'm doing something wrong but i'm not able to find anyfunction named "Setwindoflag" (this can be stupid but i don't know why this is happening) . And i'f i'm using "setwindowflags" this function is closing the complete page.At no point do I see
Setwindoflag
[sic.] written by any of us, so why do you write that? Did you search in the documentation forsetWindowFlag
, where you would have come across https://doc.qt.io/qt-5/qwidget.html#setWindowFlag? Not too hard to find. I have no idea what you mean by "And i'f i'm using "setwindowflags" this function is closing the complete page.", but never mind.In your code I see:
//setWindowFlags(Qt::FramelessWindowHint);
this->setWindowFlags(Qt::FramelessWindowHint,true);
I don't think the second line should even compile.
You have a class named
Menu
which derives fromQDialog
. This is not a helpful name, especially since Qt has aQMenu
which is what I initially thought your code would be about. You might like to think about renaming that.You have pasted hundreds of lines of your code when all you are asking is how to suppress the dialog's title bar.
You need to try exactly what we have been saying. In place of your own attempts at the start of
Menu::Menu()
, have you tried:setWindowFlag(Qt::FramelessWindowHint, true);
If you have, and it gives
error: 'setWindowFlag' was not declared in this scope
then I would guess you are on a Qt version prior to 5.9? In which case (apart from why not a later one?) it would really help if you said so! As you can see from the doc page,
setWindowFlag()
was introduced in Qt 5.9. If you are earlier try instead:setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
Please use copy & paste to ensure you get this as written.
At that point, does it indeed compile and get rid of the dialog's title bar, as I believe you were asking for?
I have had my grump in this reply :) I hope the above does work for you.