[PyQt] Combobox inside a delegate in a proxy widget

2013-01-18 Thread Selim Tuvi
I have a QGraphicsScene and inside it I have a proxy widget with a
QListWidget that has a delegate which creates a QComboBox

When I trigger the editing by clicking on an item in the list widget, I can
use the keyboard to navigate between the items in the combo box but as soon
as I use the mouse to open up the drop down list of the combo box, it
immediately closes. I am attaching a simple example.

I tried messing with the focus events, installing an event filter but none
of them work.

I am using Qt 4.7 and PyQt 4.8.6.

I have also verified this with a C++ Qt app so PyQt has nothing to do with
the problem. Also with Qt 5.0, using the mouse causes the app to crash as
soon as I try to open up the combo drop down.

Thanks
-Selim


simple_scene.py
Description: Binary data
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Subclass of QGraphicsObject does not have the correct class name listed in QGraphicsScene.items()

2011-05-20 Thread Selim Tuvi
Hi Phil, thanks for the explanation. The issue came up where I need to 
do special processing based on the type of the item. I'll rely on my own 
"itemtype" property instead.

-Selim

Phil Thompson wrote:

On Thu, 19 May 2011 14:42:47 -0700, Selim Tuvi
 wrote:
  

The code below outputs:

[<__main__.Edge object at 0x2aaab0395830>, object at 0x2aaab03958c0>]


which lists the Node instance as having the class QGraphicsItem when it 
should say <__main__.Node object at ...>.


Tested on (Qt 4.7.2, PyQt 4.8.3) and (Qt 4.6.1, PyQt 4.7.2)

Thanks
-Selim

from PyQt4 import QtGui, QtCore

class Node(QtGui.QGraphicsObject):
def __init__(self):
QtGui.QGraphicsObject.__init__(self)
   
def paint(self, painter, option, widget):

pass
   
def boundingRect(self):

return QtCore.QRectF()

class Edge(QtGui.QGraphicsItem):
def __init__(self):
QtGui.QGraphicsItem.__init__(self)

def paint(self, painter, option, widget):
pass

def boundingRect(self):
return QtCore.QRectF()

if __name__ == '__main__':
import sys
app = QtGui.QApplication(sys.argv)
print QtCore.QT_VERSION_STR, QtCore.PYQT_VERSION_STR
view = QtGui.QGraphicsView()
scene = QtGui.QGraphicsScene()
view.setScene(scene)
scene.addItem(Node())
scene.addItem(Edge())
print scene.items()
view.show()
sys.exit(app.exec_())



It's because QGraphicsObject inherits both QObject and QGraphicsItem.
items() returns a list of QGraphicsItems which, for a QGraphicsObject, has
a different C++ address than the original QGraphicsObject. PyQt doesn't
recognise that the QGraphicsItem is a cast of the QGraphicsObject. I don't
think there is anything I can (sensibly) do about this.

Phil
  
<>___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[PyQt] Subclass of QGraphicsObject does not have the correct class name listed in QGraphicsScene.items()

2011-05-19 Thread Selim Tuvi

The code below outputs:

[<__main__.Edge object at 0x2aaab0395830>, object at 0x2aaab03958c0>]


which lists the Node instance as having the class QGraphicsItem when it 
should say <__main__.Node object at ...>.


Tested on (Qt 4.7.2, PyQt 4.8.3) and (Qt 4.6.1, PyQt 4.7.2)

Thanks
-Selim

from PyQt4 import QtGui, QtCore

class Node(QtGui.QGraphicsObject):
   def __init__(self):
   QtGui.QGraphicsObject.__init__(self)
  
   def paint(self, painter, option, widget):

   pass
  
   def boundingRect(self):

   return QtCore.QRectF()

class Edge(QtGui.QGraphicsItem):
   def __init__(self):
   QtGui.QGraphicsItem.__init__(self)

   def paint(self, painter, option, widget):
   pass

   def boundingRect(self):
   return QtCore.QRectF()

if __name__ == '__main__':
   import sys
   app = QtGui.QApplication(sys.argv)
   print QtCore.QT_VERSION_STR, QtCore.PYQT_VERSION_STR
   view = QtGui.QGraphicsView()
   scene = QtGui.QGraphicsScene()
   view.setScene(scene)
   scene.addItem(Node())
   scene.addItem(Edge())
   print scene.items()
   view.show()
   sys.exit(app.exec_())

<>___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[PyQt] QProxyStyle

2011-05-12 Thread Selim Tuvi

Hi, could you explain the reasons why QProxyStyle is not exposed in PyQt4?

Thanks
-Selim

<>___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] qtreewidget only printing first character of my strings

2011-04-21 Thread Selim Tuvi
That's because the following constructor is being used when you call 
QTreeWidgetItem(hdr, x):

*
*QTreeWidgetItem ( QTreeWidgetItem * parent, const QStringList & 
strings, int type = Type )


so it is treating your string as a list of strings. Since your column 
count is 1, you are only seeing the first character. You need to change 
your code as follows:


QTreeWidgetItem(hdr, [x])

-Selim

Jason Rahm wrote:


Here's my code:

 


selected = None

self.treeWidget_iRulesList.clear()

self.treeWidget_iRulesList.setColumnCount(1)

self.treeWidget_iRulesList.setHeaderLabels(["Rules"])

self.treeWidget_iRulesList.setItemsExpandable(True)

 


for item in allrules.keys():

#print item

hdr = QTreeWidgetItem(item)

self.treeWidget_iRulesList.addTopLevelItem(hdr)

self.treeWidget_iRulesList.expandItem(hdr)

for x in allrules[item]:

#print x

rule = QTreeWidgetItem(hdr, x)

self.treeWidget_iRulesList.addTopLevelItem(rule)

 

If I uncomment my print statements, each string is printed as 
expected, but in the QTreeWidget, I only get the first character:


 


-g

g

t

t

-l

h

u

_

 


And so on.  Any ideas?  Thanks in advance.

 


Jason

 




___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
<>___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Spacing between tabs in QTabWidget etc...

2009-12-11 Thread Selim Tuvi
You should be able to use stylesheets to modify the tab margins. See the 
docs for details:

http://doc.trolltech.com/4.5/stylesheet-examples.html#customizing-qtabwidget-and-qtabbar

example:

QTabBar::tab {
   margin-left: 5;

   margin-right: 5;

}


The docs also provide examples on how to change the background color.
-Selim

Jebagnana Das wrote:

Hi all,

 I have two questions regarding QTabWidget..
1)Is it possible for us to leave space between the tab 
headers(between tab1 and tab2 in the header in this picture)... 
http://i48.tinypic.com/r2uhxf.jpg 
  
If yes could you tell me how it can be done??


2)Can we change the background color of only the headers(tab1 and 
tab2) but not completely?? or shall we place a readymade image instead 
of the tab header??


Your suggestions are much awaited...

Jeba 



___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
<>___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt