Results 1 to 3 of 3

Thread: How to add a custom minimize button in PyQt5 as i am getting a TypeError?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to add a custom minimize button in PyQt5 as i am getting a TypeError?

    The min() function is, indeed, a standard Python function but it not the root cause of the message.

    The mousePressEvent() function has two arguments:
    • the object pointer
    • the QMouseEvent

    Your implementation only takes one argument.
    This works better:
    Qt Code:
    1. def min(self, event):
    2. self.setWindowState(self.windowState() | QWindow.Minimized)
    3. event.accept()
    To copy to clipboard, switch view to plain text mode 
    I am not entirely sure it a clean approach though.
    I would also consider:
    • making the three buttons actual QPushButtons and doing this plumbing with signal/slot connections rather than hijacking the event handler
    • Using layouts to place widgets within the parent widget
    Last edited by ChrisW67; 2nd January 2020 at 23:42.

  2. The following user says thank you to ChrisW67 for this useful post:

    d_stranz (3rd January 2020)

Similar Threads

  1. How to add a custom minimize button in PyQt5?
    By AbhaySalvi in forum Newbie
    Replies: 0
    Last Post: 2nd January 2020, 09:54
  2. Replies: 3
    Last Post: 8th September 2018, 09:15
  3. Minimize button problem
    By lin3398032 in forum Newbie
    Replies: 0
    Last Post: 16th March 2018, 18:22
  4. Reimplementation Minimize button
    By clousque in forum Newbie
    Replies: 5
    Last Post: 13th May 2014, 15:21
  5. Replies: 1
    Last Post: 5th September 2012, 07:16

Tags for this Thread

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.