Getting QGraphicsView with a pixmap to Zoom and Scroll Like the Window’s Photo Viewer

November 15th, 2012

This took me forever to figure out.  I noticed lots of people online had the same question but few got it working properly and some had to do a hack.  Here is the clean way to do this.  The trick is in setTransformationAnchor() and setDragMode()

My setup code in my QDailogs __init__ function:

imageFilename = QFileDialog.getOpenFileName(self,'select image')
self._pixMap = QPixmap.fromImage(QImage(imageFilename)) 
self._graphicsScene = QGraphicsScene(self)
self._graphicsScene.addPixmap(self._pixMap)
self._view = MyGraphicsView()
self._view.setScene(self._graphicsScene)

# Create a vertical layout.
self._layout = QVBoxLayout()
self._layout.setMargin(0)
self._layout.setSpacing(0)

# Add label widget
self._layout.addWidget(self._view)
# set widget to layout
self.setLayout(self._layout)

 

Here is my implementation of the MyGraphicsView class.  Derived from QGraphicsView

class MyGraphicsView(QGraphicsView):
    def __init__(self):
        QGraphicsView.__init__(self)
        self.setRenderHints(QPainter.Antialiasing|QPainter.SmoothPixmapTransform)
        self.setTransformationAnchor(QGraphicsView.AnchorUnderMouse)
        self.setDragMode(QGraphicsView.ScrollHandDrag)
    def wheelEvent(self,event):        
        adj = (event.delta()/120) * 0.1
        self.scale(1+adj,1+adj)

Glider Ride

September 10th, 2012

Went out to Ridge Soaring Gliderport for a flight last Friday.  Doris Grove was my awesome pilot. Check it…

 

Morocco Trip – 2011

March 8th, 2012

Would like to write something about this eventually.  Here are some pics.

This was a last minute trip literally — booked my plane tickets and a week later was in Casablanca.  Would like to write something about budget travel, traveling like you live there, and how you don’t need to have a plan to travel but still be safe.

The Fisherman and the Businessman

October 13th, 2011

There was once a businessman who was sitting by the beach in a small Brazilian village. As he sat, he saw a Brazilian fisherman rowing a small boat towards the shore having caught quite few big fish. The businessman was impressed and asked the fisherman, “How long does it take you to catch so many fish?”

The fisherman replied, “Oh, just a short while.”

“Then why don’t you stay longer at sea and catch even more?” The businessman was astonished.

“This is enough to feed my whole family,” the fisherman said.

The businessman then asked, “So, what do you do for the rest of the day?”

The fisherman replied, “Well, I usually wake up early in the morning, go out to sea and catch a few fish, then go back and play with my kids. In the afternoon, I take a nap with my wife, and evening comes, I join my buddies in the village for a drink — we play guitar, sing and dance throughout the night.”

The businessman offered a suggestion to the fisherman. “I am a PhD in business management. I could help you to become a more successful person. From now on, you should spend more time at sea and try to catch as many fish as possible. When you have saved enough money, you could buy a bigger boat and catch even more fish. Soon you will be able to afford to buy more boats, set up your own company, your own production plant for canned food and distribution network. By then, you will have moved out of this village and to Sao Paulo, where you can set up HQ to manage your other branches.”

The fisherman continues, “And after that?”

The businessman laughs heartily, “After that, you can live like a king in your own house, and when the time is right, you can go public and float your shares in the Stock Exchange, and you will be rich.”

The fisherman asks, “And after that?”

The businessman says, “After that, you can finally retire, you can move to a house by the fishing village, wake up early in the morning, catch a few fish, then return home to play with your kids, have a nice afternoon nap with your wife, and when evening comes, you can join your buddies for a drink, play the guitar, sing and dance throughout the night!”

The fisherman smiled.

Source.

How to Delete a Motoblur Account (Atrix)

April 8th, 2011

I recently got a phone with Motoblur on it.  I love the phone, but have had problems with Motoblur right from the get go.  Here’s what happened..

I turn on my newly purchased phone and register for Motoblur.  I then begin to add my facebook account.  I see my facebook friends now being imported into my contacts list.  All of a sudden, the process halts.  I chill for a few hours and inspect my contacts list again — no luck, the import only half worked.  So, I decide just to delete my facebook entry in Motoblur and start over.

No such luck.  I go Menu -> Social Networking and see Facebook listed under “Motoblur Accounts”.  It has a green checkmark.  I go to my contacts (blue button)->menu->manage accounts and DON’T see facebook listed there.  I go back to the Social Networking app and try to add or adjust my facebook account settings but all it tells me is that you can only register one facebook account with Motoblur.  Great :(  So now, a part of Motoblur thinks facebook is installed and a part of it doesn’t.

I think that by doing a soft reset of the phone that the problem will go away.  Nope.  I do a hard reset.  Nope.  I clear the internal phone memory and then do said resets.  Still no.  I then do the remote wipe from the Motoblur website and STILL, no luck.  FYI, the remote wipe does not wipe the internal phone storage and thus, any music files, etc you store on the phone that are accessibly through the “Files” button are still available for prying eyes — quite the misadvertisement in my opinion.

So, I eventually conclude that the only way to fix this problem is to delete my Motoblur account and start over from scratch.   The short story is that this worked and now Motoblur is working smoothly.  Here’s how I deleted my Motoblur account (after several experiements).

  1. Call AT&T customer service and tell them that you want your Motoblur account deleted and that they need to call Motorola, in a 3-way call (yes, I did this and it worked), to verify your identity.
  2. Tell the ATT operator to call 800 734 5870.
  3. Once on the 3-way call, politely ask the Motorola agent that you want your Motoblur account deleted and that you have an agent from ATT on the line to verify your identity.
  4. Ask when you expect the account to be inactive.
  5. Politely thank both agents.
  6. Hang up.

That’s it.  Well, kind of…

I was told that my account would be deleted within 24 hours yet over 30 hours later, I could still login to Motoblur via the web.  I called around a few times to get this fixed and finally arrived at this solution:

  1. Call Motorola 800 734 5870
  2. Ask for “Level 2″ support and tell them you have an Atrix.
  3. Tell them your account was not deleted and that you want it deleted immediately.  Tell them you already had your identity verified by ATT with Motorola (there should be a log of this on Motorola’s side).

I did a soft reset (factory reset) and then resubscribed to Motoblur and this fixed all my issues.  Facebook and Google now live in harmony in my contacts list on my Atrix.

Hopefully Motorola fixes this buggy Motoblur software soon.