3

I'm developping a text editor with PyQt5 and I want to create my own "title bar". enter image description here I've created my own title bar and I have something just like the image above. The only problem is the window's frame. So far I've been using:

setWindowFlags(Qt.FramelessWindowHint) 

But I just realised that with this flag there is no frame (cause it's "Frameless") and without the frame I can't resize my window by dragging the border.

I've tried CustomizeWindowHint flag but the title bar is still there, just without icon, name and buttons.

A temporary solution is to detect whenenver the mouse enter the window by installing eventFilter, get its positions, if it's on the border then we have to change the cursor icon (up, left, down, left-up, left-down,...) and if the user drags then calculate and resize window.

Another solution is to set 8 QSizegrip at every corner of the window but we will have to somehow hide those grips and make sure that they don't take any space because we will add 3 grips at the TOP of the title bar so it will be ugly.

But I don't really like these solutions. So is there anyway that I can hide the title bar and keep the frame?

NewBieBR
  • 344
  • 1
  • 5
  • 16
  • If you've looked at other questions on SO that try to implement custom title-bars, please add links to them and briefly explain why they don't work for you. Without this, there is some danger that your question will be closed as a duplicate. Presumably, your question has much more to do with implementing a custom *frame* (with resizing) than a title-bar. – ekhumoro Sep 05 '17 at 12:19
  • 1
    Well I just edited my post hope that it's more clear now. – NewBieBR Sep 05 '17 at 13:44
  • 1
    It would be helpful if you said which os you are using, because it's likely some potential solutions won't be cross-platform. I read somewhere that `setWindowFlags(Qt.Tool|Qt.CustomizeWindowHint)` can give a frame with no title-bar, but I tried it on my linux system and it didn't work for me. – ekhumoro Sep 05 '17 at 14:03
  • I use window and macOs, it doesn't work for me neither. – NewBieBR Sep 05 '17 at 14:13
  • From what I've read so far, there is no simple, reliable, cross-platform way to hide the title-bar and keep the frame. By "simple", I mean using the public Qt APIs (like `setWindowFlags`). It may be possible to do it by hooking into low-level window events, but I think that will be very hard (or probably impossible) to achieve using pyqt. So the only reasonable solution seems to be to use `Qt.FramelessWindowHint` and create your own custom frame. I imagine that could be quite a lot of work, though, if you want to reproduce all the normal functionality (and do it all in a cross-platform way). – ekhumoro Sep 05 '17 at 14:30
  • Well if there really is no easy solution maybe I'll go with the 1st solution mentionned in my post. Just like you said there will be a lot of work for that though – NewBieBR Sep 05 '17 at 14:55

0 Answers0