Results 1 to 5 of 5

Thread: Overloading QGraphicsView function from Qt Designer

  1. #1
    Join Date
    Nov 2011
    Posts
    5
    Qt products
    PyQt3 PyQt4
    Platforms
    Windows
    Thanks
    1

    Default Overloading QGraphicsView function from Qt Designer

    Hello!

    I'm having a bit of trouble with overloading a function for a QGraphicsView of mine. The QGraphicsView was created in Qt Designer and is called nodeDropWindow. In this example I'm trying to overload the wheelEvent but I just want to get anything working. This is in my mainForm() class where setupUI is called. From my understanding all I would have to implement is:

    Qt Code:
    1. @pyqtSignature("QEvent")
    2. def on_nodeDropWindow_wheelEvent(self, event):
    3. print("Hi!")
    To copy to clipboard, switch view to plain text mode 

    So what I"m trying to do is just get my console to print "Hi!" whenever I use my mouse wheel over the graphics window. This seems so simple to me but I can't get it working :-( Anybody have any ideas? Thanks!
    Last edited by drumboy354; 15th November 2011 at 20:16.

  2. #2
    Join Date
    Nov 2011
    Posts
    5
    Qt products
    PyQt3 PyQt4
    Platforms
    Windows
    Thanks
    1

    Default Re: Overloading QGraphicsView function from Qt Designer

    No one has any ideas on how to hook up functions to a widget in Qt Designer? :-(

  3. #3
    Join Date
    Nov 2011
    Posts
    5
    Qt products
    PyQt3 PyQt4
    Platforms
    Windows
    Thanks
    1

    Default Re: Overloading QGraphicsView function from Qt Designer

    Sorry another response: I explained the problem in a lot more detail and posted some code if anyone cares :-)

    http://www.qtforum.org/article/36967...tml#post115806

  4. #4
    Join Date
    Feb 2008
    Posts
    491
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11
    Thanks
    12
    Thanked 142 Times in 135 Posts

    Default Re: Overloading QGraphicsView function from Qt Designer

    QGraphicsView::wheelEvent() is not a signal so there is nothing to connect. What you want to do is override wheelEvent() not overload it.

    I've just dabbled in Python so I'm not sure this is correct, but at the bottom of your mainWindow class add the following and delete the "self.connect" statement:
    Qt Code:
    1. // added this line so next line would indent
    2. self.nodeDropGraphicsView.wheelEvent = self.wheelEvent
    3.  
    4. def wheelEvent(self, event):
    5. print("wheel event")
    To copy to clipboard, switch view to plain text mode 

  5. The following user says thank you to norobro for this useful post:

    drumboy354 (17th November 2011)

  6. #5
    Join Date
    Nov 2011
    Posts
    5
    Qt products
    PyQt3 PyQt4
    Platforms
    Windows
    Thanks
    1

    Default Re: Overloading QGraphicsView function from Qt Designer

    Ohh man that was it! Dang okay I was definitely confusing the wheelEvent with a signal. Dang that's confusing. I think I was thinking that when the mouse wheel is scrolled it emits a signal (or something) and that's where I was getting confused. That makes a lot more sense, thanks a lot norobro!

Similar Threads

  1. overloading paintEvent() function
    By Aayush in forum Qt Programming
    Replies: 5
    Last Post: 20th July 2011, 20:59
  2. How to use QGraphicsView in designer
    By dpatel in forum Qt Programming
    Replies: 3
    Last Post: 6th June 2011, 12:51
  3. Replies: 3
    Last Post: 27th August 2010, 07:00
  4. Replies: 1
    Last Post: 30th July 2010, 08:50
  5. QGraphicsView scale function
    By forrestfsu in forum Qt Programming
    Replies: 2
    Last Post: 12th October 2006, 15:05

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
  •  
Qt is a trademark of The Qt Company.