Reputation: 180
I want set MainWindow title in two lines, like:
WINDOW
TRACKER
I tried to use :
this->setWindowTitle("WINDOW \nTRACKER");
but the result was WINDOW TRACKER
in one line.
Any way is it possible to do it?
Thanks!
Upvotes: 1
Views: 1544
Reputation: 126927
The titlebar text layout is mostly besides Qt's control, typically Qt just passes its caption straight to the window manager, and most window managers (including the one of Windows) don't support multiline text in the window caption.
If you want to do this kind of customization in a reliable way, you should create a borderless window and draw your own window decoration (the title bar, the window border, ...), handle all the relevant events (dragging on your "fake title bar" area should move the window, clicking on your "fake maximize" button should maximize the window, ...) and so on; it is definitely possible and gives you full control on everything, but it's quite tedious, and, most importantly, makes your application look completely foreign to the environment it's running in.
In short, I'd just avoid it.
Upvotes: 3
Reputation: 149
What you are wanting to do is possible by creating a QString and telling setWindowTitle to use it like this.
QString windowTitle("WINDOW \n TRACKER);
this->setWindowTitle(windowTitle);
There's one problem though as was already mentioned in a comment by @Tusher. The size of the top bar containing the window title isn't large enough to contain two lines of text. Unfortunately, QMainWindow does not support or offer the option of a two-lined window title. The code above produces the following ugly result.
Upvotes: 1