Results 1 to 12 of 12

Thread: Window customization

  1. #1
    Join Date
    Sep 2007
    Posts
    21
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Window customization

    Hello there,
    I have two questions:

    1. How to remove this border from the main window:


    2. How can I move my window from my "Title frame" ?
    I'm trying with mouseMoveEvent, but my calculations are wrong.

    Thanks to all.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Window customization

    1. See Qt::FramelessWindowHint
    2. See wiki article: [WIKI]Moving widgets[/WIKI]
    J-P Nurmi

  3. The following user says thank you to jpn for this useful post:

    Kostanev (30th March 2008)

  4. #3
    Join Date
    Aug 2007
    Posts
    166
    Thanks
    16
    Thanked 14 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Window customization

    Hello, I followed the tutorial, on first look seems to work fine but when I click on a some control like button or slider and I move the mouse the main window start to jump and the mouse is moved to the top left corner of the window. Any fix for this ?

  5. #4
    Join Date
    Aug 2007
    Posts
    166
    Thanks
    16
    Thanked 14 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Window customization

    Anyone, please.

  6. #5
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Window customization

    Cant really tell without seeing what you are doing.
    Can we see what are you doing ?

  7. #6
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Window customization

    post some code, please.

  8. #7
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Window customization

    The problem seems to be that QSlider basically always accepts mouse press events but ignores mouse move events in case the user pressed outside the slider handle. Furthermore, ignored events are propagated to the parent, which means that the window doesn't receive a press event but a move event directly, thus offset is not calculated and the window jumps to wrong location. One solution could be to subclass and ensure that appropriate events are accepted. I guess you wouldn't like to move the window by dragging from a slider.
    Qt Code:
    1. void MySlider::mouseMoveEvent(QMouseEvent* event)
    2. {
    3. QSlider::mouseMoveEvent(event);
    4. event->accept();
    5. }
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  9. #8
    Join Date
    Aug 2007
    Posts
    166
    Thanks
    16
    Thanked 14 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Window customization

    Quote Originally Posted by aamer4yu View Post
    Cant really tell without seeing what you are doing.
    Can we see what are you doing ?
    The code is in to the wiki page that the link is above, I do it in the very same way by subclassing QMainWindow.

    @jpn Yes I don't want the window to move when I'm clicking some of the components like the slider, but if I inherit all of them I will not be able to use the Qt Designer at all.

  10. #9
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Window customization

    Quote Originally Posted by The Storm View Post
    but if I inherit all of them I will not be able to use the Qt Designer at all.
    Actually you can (check the link) but it won't be very convenient...
    J-P Nurmi

  11. #10
    Join Date
    Aug 2007
    Posts
    166
    Thanks
    16
    Thanked 14 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Window customization

    Well maybe is possible some hack to ignore the move event if a press event hasn't been called ?

  12. #11
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Window customization

    Quote Originally Posted by The Storm View Post
    Well maybe is possible some hack to ignore the move event if a press event hasn't been called ?
    Sure, that's another, maybe even better way.
    J-P Nurmi

  13. #12
    Join Date
    Aug 2007
    Posts
    166
    Thanks
    16
    Thanked 14 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Window customization

    Done, it works perfect with just one more bool variable.
    Here's the result of code
    Qt Code:
    1. void mousePressEvent(QMouseEvent *event)
    2. {
    3. event->accept(); // do not propagate
    4. if (isWindow())
    5. offset = event->globalPos() - pos();
    6. else
    7. offset = event->pos();
    8.  
    9. MousePressEventCalled = true;
    10. }
    11.  
    12. void mouseReleaseEvent(QMouseEvent *event)
    13. {
    14. event->accept(); // do not propagate
    15. offset = QPoint();
    16. MousePressEventCalled = false;
    17. }
    18.  
    19. void mouseMoveEvent(QMouseEvent *event)
    20. {
    21. if (!MousePressEventCalled)
    22. {
    23. event->ignore();
    24. return;
    25. }
    26.  
    27. event->accept(); // do not propagate
    28. if (isWindow())
    29. move(event->globalPos() - offset);
    30. else
    31. move(mapToParent(event->pos() - offset));
    32. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Set a window as child at runtime
    By sabeesh in forum Qt Programming
    Replies: 1
    Last Post: 26th November 2007, 09:30
  2. Replies: 3
    Last Post: 23rd November 2007, 11:40
  3. Change shape of window / animate window
    By sabeesh in forum Qt Programming
    Replies: 3
    Last Post: 31st October 2007, 08:16
  4. Replies: 1
    Last Post: 11th September 2007, 13:34
  5. move parent window to the front.
    By hvengel in forum Qt Programming
    Replies: 4
    Last Post: 2nd February 2007, 08:41

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.