[PyQt] [PyQt 4.5 Bug] Derived signals do not present

2009-04-09 Thread Alexandr N Zamaraev

Code for reproduce:
[code=python]
from PyQt4 import QtGui

sm = QtGui.QSortFilterProxyModel()
sm.modelReset.conncet(lambda: None)
[/code]
Traceback (most recent call last):
  File C:\Lang\test\python\PyQtSignalBug\QtSortProxy.py, line 4, in 
module

sm.modelReset.conncet(lambda: None)
AttributeError: 'QSortFilterProxyModel' object has no attribute 'modelReset'

Signal modelReset has in QAbstractItemModel.

Os Windows Vista Home Ru + sp1
g++ (GCC) 3.4.5 (mingw-vista special r3)
Qt 4.5 (self build)
sip-4.8-snapshot-20090401 (self build)
PyQt-win-gpl-4.5-snapshot-20090328.zip (self build)

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


Re: [PyQt] context menus for QTreeWidgetItem?

2009-04-09 Thread projetmbc

Christian Aubert a écrit :
I currently have a context menu for the whole QTreeWidget but I need 
finer-grained control on a per item basis. Has anyone implemented 
context menus for QTreeWidgetItems? Any pointers?


Christian

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



Hello,
here is a solution that works. I hope tha will help you.

To call the menu, just use :
   self.connect(self.treeWidget, 
QtCore.SIGNAL(customContextMenuRequested(const QPoint )), 
self.menuContextTree)


Here is the method menuContextTree :
  def menuContextTree(self, point):
# Infos about the node selected.
  index = self.treeWidget.indexAt(point)

  if not index.isValid():
 return

  item = self.treeWidget.itemAt(point)
  name = item.text(0)  # The text of the node.

# We build the menu.
  menu=QtGui.QMenu(self)
  action=menu.addAction(Souris au-dessus de)
  action=menu.addAction(name)
  menu.addSeparator()
  action_1=menu.addAction(Choix 1)
  action_2=menu.addAction(Choix 2)
  action_3=menu.addAction(Choix 3)

  print QtGui.QCursor.pos()
  menu.exec_(QtGui.QCursor.pos())

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


Re: [PyQt] SplashScreen and mousePressEvent

2009-04-09 Thread projetmbc
Thanks, I'll try to understand that. Maybe my problem is a problem of 
windowflag. Where are all the avaibale windowflag ?


Best reagrds and a great thanks for your help.
Christophe.


Apologies for the C++ code, we have an info label that displays text 
in a popup QFrame, this is the method that sets the text and makes the 
widget visible.


The things you will find interesting are mapping from the cursor to 
the current frame and then mapping this point (after moving out of the 
way of the mouse) to the mainwindow (which is the parent of the Qframe).


Hope this helps.

void InfoLabel::SetInfoLabel( const std::string s )
{
  if (s.empty())
  {
if (!_hidden)
{
  hide();
  _hidden = true;
}
  }
  else
  {
QPoint pos = mapFromGlobal(QCursor::pos());
setText(s.c_str());
adjustSize();

QPoint p(pos.x(), pos.y() - height());
move(this-mapTo(parent(), p));
raise();

if (_hidden)
  show();
else
  update();

_hidden = false;
  }
}


On 4/8/09 11:40 AM, projetmbc projet...@club-internet.fr wrote:

Brian Kelley a écrit :
 You can have the same effect using a timer:

 class MyFrame(QFrame):
 def __init__(self, parent, pixmapfile):
 QFrame.__init__(self, parent,
 Qt.X11BypassWindowManagerHint |
 Qt.FramelessWindowHint |
 Qt.WindowStaysOnTopHint | Qt.Tool )

 # do something with pixmapfile


 self.timer = QTimer()
 self.connect( self.timer, QtCore.SIGNAL(timeout()),
   self,   QtCore.SLOT(hide()) )

 def showEvent(self, evt):

 self.timer.start(3000) # 3 seconds
 QFrame.showEvent(self, evt)


 On 4/8/09 9:39 AM, projetmbc projet...@club-internet.fr wrote:

 You're right. I will try to do that with a frame but the
adventage
 of a
 SplashScreen is that it lives for a laps of time.

 Best regards.
 Christophe.
 Qt.X11BypassWindowManagerHint | Qt.FramelessWindowHint |
  Qt.WindowStaysOnTopHint | Qt.Tool

I do the following changes but there is still a very little problem
concerning the position of the frame. How can I do to use
QtGui.QCursor.pos()  so as to put the frame where the mouse is ?
I've tried to use  rect=QtCore.QRect(position,
QtCore.QPoint(1000,1000))  and  self.setFrameRect(rect)  but it
doesn't
work.

Christophe.


Code


class MyFrame(QtGui.QFrame):
# Squelette donné par Brian Kelley sur la liste de PyQt.
def __init__(self, parent, titre, pixmapfile, position):
QtGui.QFrame.__init__(self, parent,
QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.Tool)
#  QtCore.Qt.X11BypassWindowManagerHint |
QtCore.Qt.FramelessWindowHint
| QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.Tool
self.setWindowTitle(titre)
  
label = QtGui.QLabel(self)

label.setPixmap(pixmapfile)
label.show()

self.timer = QtCore.QTimer()
self.connect( self.timer, QtCore.SIGNAL(timeout()),
self,QtCore.SLOT(hide()) )
  
def showEvent(self, evt):

self.timer.start(1) # 10 seconds
QtGui.QFrame.showEvent(self, evt)





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


Re:Re: [PyQt] context menus for QTreeWidgetItem?

2009-04-09 Thread projetmbc

Christian Aubert a écrit :
I currently have a context menu for the whole QTreeWidget but I need 
finer-grained control on a per item basis. Has anyone implemented 
context menus for QTreeWidgetItems? Any pointers?


Christian

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



Hello,
here is a solution that works. I hope tha will help you.

To call the menu, just use :
  self.connect(self.treeWidget, 
QtCore.SIGNAL(customContextMenuRequested(const QPoint )), 
self.menuContextTree)


Here is the method menuContextTree :
 def menuContextTree(self, point):
# Infos about the node selected.
 index = self.treeWidget.indexAt(point)

 if not index.isValid():
return

 item = self.treeWidget.itemAt(point)
 name = item.text(0)  # The text of the node.

# We build the menu.
 menu=QtGui.QMenu(self)
 action=menu.addAction(Souris au-dessus de)
 action=menu.addAction(name)
 menu.addSeparator()
 action_1=menu.addAction(Choix 1)
 action_2=menu.addAction(Choix 2)
 action_3=menu.addAction(Choix 3)

 print QtGui.QCursor.pos()
 menu.exec_(QtGui.QCursor.pos())


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


[PyQt] [PyQt 4.5] TypeError: pyqtBoundSignal cannot be converted to QObject in this context

2009-04-09 Thread Alexandr N Zamaraev

I try port my applications to PyQt 4.5
And I recive TypeError:
[code]
Traceback (most recent call last):
 ...
  File 
C:\Lang\Projects\Promsoft\mun_ob\doc_circ\src\links\DataRightOwner.py, 
line 48, in __init__

self.__connectAll()
  File 
C:\Lang\Projects\Promsoft\mun_ob\doc_circ\src\links\DataRightOwner.py, 
line 189, in __connectAll

for dm in (self.__phys, self.__jur, self.__bus):
TypeError: PyQt4.QtCore.pyqtBoundSignal cannot be converted to 
PyQt4.QtCore.QObject in this context

[/code]

How correct this error?

Snipped Code for illustrate:
[code]
class DataLink(QtCore.QObject):
  data_adds = QtCore.QtCore.pyqtSignal(frozenset)

class DataRightLandPhys(DataLink): pass
class DataRightLandJur(DataLink): pass
class DataRightLandJur(DataLink): pass

class Data(DataLink):
  __phys = None
  __jur = None
  __bus = None
  def __init__(self):
super(Data, self).__init__()
self.__phys = DataRightLandPhys()
self.__jur = DataRightLandJur()
self.__bus = DataRightLandBus()
self.__connectAll()

  def __connectAll(self):
for dm in (self.__phys, self.__jur, self.__bus):
  dm.data_adds.connect(self.data_adds.emit)
[/code]

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


[PyQt] Re: Connecting two QGraphicsItems

2009-04-09 Thread Wolfgang Rohdewald
On Thursday, 9. April 2009, Mads wrote:
 is it possible to control the position of the item?

just use item.setPos() - this uses a coordinate system
relative to the parent item.

-- 
Wolfgang
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] Bug: PyQt causes Python to abnormally exit upon creating QWidget without a QApplication

2009-04-09 Thread Shriramana Sharma

Hello. See the following:

$ python
Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type help, copyright, credits or license for more information.
 from PyQt4.QtGui import *
 w = QWidget ()
QWidget: Must construct a QApplication before a QPaintDevice
$

I think this should be handled more gracefully with a Python exception 
(or error, if the two are not the same) thrown rather than Python 
abnormally exiting, like follows:


$ python
Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type help, copyright, credits or license for more information.
 a=b
 c=2
 a+b
Traceback (most recent call last):
  File stdin, line 1, in module
NameError: name 'b' is not defined


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


[PyQt] will pyqt follow qt license model?

2009-04-09 Thread jelle feringa
Hi,

I've searched this mailing list and although the QT lgpl news was discussed at
 length, but I couldnt distill from this list whether pyqt will follow qt's
 licensing model. Has this been decided yet?

Thanks,

-jelle

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


Re: [PyQt] [SIP][PATCH]Errors occurring during execution of python __dtor__() function called from sip are discarded

2009-04-09 Thread Phil Thompson
On Mon, 06 Apr 2009 10:04:35 +0200, Alexis Boutillier
alexis.boutill...@arteris.com wrote:
 Hi,
 
 When sip call the __dtor__() python function on a python object, it does 
 not print errors that occurred during the execution of the python
function.
 If something goes wrong in this function you are not informed and so you 
 can leave objects in an unwanted state (because of an attributeError for 
 example).
 
 Here is a patch to siplib.c that print the python error if it occurred 
 during the call of the python __dtor__() function.

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


Re: [PyQt] Possible bug - global coordinates work but widget coordinates do not

2009-04-09 Thread Phil Thompson
On Wed, 08 Apr 2009 20:26:55 +0530, Shriramana Sharma samj...@gmail.com
wrote:
 Hello first of all let me clarify that this is specific to PyQt and does
 not existing in C++/Qt.
 
 I am using PyQt 4.3.3 on Qt 4.4.0 on Kubuntu Hardy.
 
 I attach three files.
 1. test.py is the one that demonstrates the problem.
 2. test.cpp is the equivalent C++ version that shows no problem.
 3. test-sol.py is the Python version that works.
 
 I wanted to draw a rubberband on a widget, and ended up finding this
 bug. Everytime the mouseMoveEvent is processed, the value of the
 variable rbOrigin (origin of the rubberband) is reset to the current
 event position, thereby making it impossible for a proper rubberband to
 be drawn. However, it appears that the mousePressEvent (which sets the
 value of rbOrigin) is definitely not called by mistake as I don't get
 any debug output.
 
 The equivalent C++ version works without problems.
 
 Using global coordinates on Python works around the bug but I don't see
 why.

See...

http://www.riverbankcomputing.com/software/pyqt/roadmap/index.html#implicit-copying-of-const

Making an explicit copy of event.pos() in mousePressEvent() will probably
fix it.

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


Re: [PyQt] Re: Connecting two QGraphicsItems

2009-04-09 Thread Mads

Thanks for the replies.

Using setParent works fine for one item, but is it possible to control the 
position of the item? I mean is it possible to place the EllipseItem at a 
certain point on the GraphicsItem, so the EllipseItems don't get placed at the 
same point.

Mads




- Original Message 
From: Wolfgang Rohdewald wolfg...@rohdewald.de
To: pyqt@riverbankcomputing.com
Sent: Tuesday, April 7, 2009 12:34:47 AM
Subject: [PyQt] Re: Connecting two QGraphicsItems

On Montag, 6. April 2009, Marcell Mars wrote:
 On Mon, Apr 6, 2009 at 4:13 PM, Mads kofo...@yahoo.com wrote:
  each item needs to have separate functionality, so you should be able to 
  set different
  attributes on each item. Is the createItemGroup, still the best way forward?
 
 to be more sure i would need more info about your app but as i saw i
 would definitively try createItemGroup and QGraphicsView.. i love
 QGraphicsView 

why not simply make the 3 circles children of the rectangle with
circle.setParentItem(rectangle)? The drawing seems to say that the line of
the rectangle should not be visible below the circles.

-- 
Wolfgang
___
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] SplashScreen and mousePressEvent - SOLVED

2009-04-09 Thread projetmbc
Hello. Finaly here is the solution to have a frame where the cursor is. 
We have to use setGeomtry and not setRectangle.


Best regards.
Christophe.

==
THE CODE
==
class MyFrame(QtGui.QFrame):
   def __init__(self, parent, titre, pixmapfile):
   QtGui.QFrame.__init__(self, parent, 
QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.Tool)


   rect = QtCore.QRect(QtGui.QCursor.pos(), pixmapfile.size())
   self.setGeometry(rect)
  
   label = QtGui.QLabel(self)

   label.setPixmap(pixmapfile)
   label.show()

   self.timer = QtCore.QTimer()
   self.connect( self.timer, QtCore.SIGNAL(timeout()),
 self,   QtCore.SLOT(hide()) )
  
   def showEvent(self, evt):

   self.timer.start(1) # 10 seconds
   QtGui.QFrame.showEvent(self, evt)


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


Re: [PyQt] Bug: PyQt causes Python to abnormally exit upon creating QWidget without a QApplication

2009-04-09 Thread Andreas Pakulat
On 09.04.09 13:45:47, Shriramana Sharma wrote:
 Hello. See the following:

 $ python
 Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52)
 [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
 Type help, copyright, credits or license for more information.
  from PyQt4.QtGui import *
  w = QWidget ()
 QWidget: Must construct a QApplication before a QPaintDevice
 $

 I think this should be handled more gracefully with a Python exception  
 (or error, if the two are not the same) thrown rather than Python  
 abnormally exiting, like follows:

PyQt has no control over that, this is happening in the C++ part and
QWidget uses qFatal() which in turn calls abort() at that point to end
the application. And thats actually the correct way for the C++ part to
handle this case (as Qt doesn't use exceptions).

Andreas

-- 
You definitely intend to start living sometime soon.
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] [PyQt 4.5 Bug] Derived signals do not present

2009-04-09 Thread Phil Thompson
On Thu, 09 Apr 2009 13:15:24 +0700, Alexandr N Zamaraev to...@promsoft.ru
wrote:
 Code for reproduce:
 [code=python]
 from PyQt4 import QtGui
 
 sm = QtGui.QSortFilterProxyModel()
 sm.modelReset.conncet(lambda: None)
 [/code]
 Traceback (most recent call last):
File C:\Lang\test\python\PyQtSignalBug\QtSortProxy.py, line 4, in 
 module
  sm.modelReset.conncet(lambda: None)
 AttributeError: 'QSortFilterProxyModel' object has no attribute
 'modelReset'
 
 Signal modelReset has in QAbstractItemModel.
 
 Os Windows Vista Home Ru + sp1
 g++ (GCC) 3.4.5 (mingw-vista special r3)
 Qt 4.5 (self build)
 sip-4.8-snapshot-20090401 (self build)
 PyQt-win-gpl-4.5-snapshot-20090328.zip (self build)

Should be fixed in tonight's PyQt snapshot - there was a whole group of
signals missing from the .sip file.

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


Re: [PyQt] QAbstractItemModel modelAboutToBeReset signal

2009-04-09 Thread Phil Thompson
On Wed, 8 Apr 2009 11:55:39 -0400, Patrick Boucher
pbouc...@patrickboucher.com wrote:
 Hi all,
 
 I've subclassed QAbstractItemModel and overloaded reset to be:
 
 def reset(self):
 self.modelAboutToBeReset.emit()
 self._loadPeople()
 self.modelReset.emit()
 
 and I get errors pertaining to missing attributes modelAboutToBeReset
 and modelReset. Do I have something wrong with the new syntax for
 emitting signals or is this a known thing or a bug? I'm using latest
 snapshots of sip and pyqt.
 
 The pre-4.5 version of the code works fine:
 
 def reset(self):
 self.emit(QtCore.SIGNAL('modelAboutToBeReset()'))
 self._loadPeople()
 self.emit(QtCore.SIGNAL('modelReset()'))

Should be fixed in tonight's PyQt snapshot.

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


Re: [PyQt] [PyQt 4.5] TypeError: pyqtBoundSignal cannot be converted to QObject in this context

2009-04-09 Thread Phil Thompson
On Thu, 09 Apr 2009 15:13:27 +0700, Alexandr N Zamaraev to...@promsoft.ru
wrote:
 I try port my applications to PyQt 4.5
 And I recive TypeError:
 [code]
 Traceback (most recent call last):
   ...
File 
 C:\Lang\Projects\Promsoft\mun_ob\doc_circ\src\links\DataRightOwner.py, 
 line 48, in __init__
  self.__connectAll()
File 
 C:\Lang\Projects\Promsoft\mun_ob\doc_circ\src\links\DataRightOwner.py, 
 line 189, in __connectAll
  for dm in (self.__phys, self.__jur, self.__bus):
 TypeError: PyQt4.QtCore.pyqtBoundSignal cannot be converted to 
 PyQt4.QtCore.QObject in this context
 [/code]
 
 How correct this error?
 
 Snipped Code for illustrate:
 [code]
 class DataLink(QtCore.QObject):
data_adds = QtCore.QtCore.pyqtSignal(frozenset)
 
 class DataRightLandPhys(DataLink): pass
 class DataRightLandJur(DataLink): pass
 class DataRightLandJur(DataLink): pass
 
 class Data(DataLink):
__phys = None
__jur = None
__bus = None
def __init__(self):
  super(Data, self).__init__()
  self.__phys = DataRightLandPhys()
  self.__jur = DataRightLandJur()
  self.__bus = DataRightLandBus()
  self.__connectAll()
 
def __connectAll(self):
  for dm in (self.__phys, self.__jur, self.__bus):
dm.data_adds.connect(self.data_adds.emit)

I don't understand what you are trying to do in the last line.

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


Re: [PyQt] QAbstractItemModel modelAboutToBeReset signal

2009-04-09 Thread Patrick Boucher
Thanks!

Patrick



On Thu, Apr 9, 2009 at 8:57 AM, Phil Thompson
p...@riverbankcomputing.com wrote:
 On Wed, 8 Apr 2009 11:55:39 -0400, Patrick Boucher
 pbouc...@patrickboucher.com wrote:
 Hi all,

 I've subclassed QAbstractItemModel and overloaded reset to be:

     def reset(self):
         self.modelAboutToBeReset.emit()
         self._loadPeople()
         self.modelReset.emit()

 and I get errors pertaining to missing attributes modelAboutToBeReset
 and modelReset. Do I have something wrong with the new syntax for
 emitting signals or is this a known thing or a bug? I'm using latest
 snapshots of sip and pyqt.

 The pre-4.5 version of the code works fine:

     def reset(self):
         self.emit(QtCore.SIGNAL('modelAboutToBeReset()'))
         self._loadPeople()
         self.emit(QtCore.SIGNAL('modelReset()'))

 Should be fixed in tonight's PyQt snapshot.

 Phil


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


[PyQt] segfault when using a proxy and SIGNAL( clicked(QModelIndex) )

2009-04-09 Thread TP
Hi everybody,

Here you will find a small (170 lines) self-contained Python script.

http://paratribulations.free.fr/help/python/simpleproxy.py

I use a model, and a proxy (that does nothing, but in a more complicated
version, not given here, it works perfectly). The view is a QTreeView.

The problem appears when I connect the SIGNAL( clicked(QModelIndex) ) to
some method cellClicked in the view, I obtain segfaults.
Difficult for me to find the problem.

Here are the most important lines:

self.view = QTreeView( parent )
self.connect( self.view, SIGNAL( clicked(QModelIndex) )
, self.cellClicked )

def cellClicked( self, qmodelindex ):

if qmodelindex.isValid():
print qmodelindex.internalPointer()

The problem seems to be related to qmodelindex, the segfault appears when
taking internalPointer method.

Any idea?

Thanks a lot.

Julien

-- 
python -c print ''.join([chr(154 - ord(c)) for c in '*9(9(18%.\
91+,\'Z4(55l4('])

When a distinguished but elderly scientist states that something is
possible, he is almost certainly right. When he states that something is
impossible, he is very probably wrong. (first law of AC Clarke)

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


Re: [PyQt] How do you close a QDialog?

2009-04-09 Thread Demetrius Cassidy

You should read the Python tutorial. It would probably help.

http://docs.python.org/tutorial/


GatorAlli wrote:
 
 Thanks! It worked! =)
 
 Now how could you run this dialog from another script?
 
 (I'm no good at self, classes, and inheritance.)
 

-- 
View this message in context: 
http://www.nabble.com/How-do-you-close-a-QDialog--tp22874235p22977765.html
Sent from the PyQt mailing list archive at Nabble.com.

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


Re: [PyQt] context menus for QTreeWidgetItem?

2009-04-09 Thread Christian Aubert

I had this from the previous contextMenu that covered the whole treeWidget:
self.treeWidget.setContextMenuPolicy(Qt.ActionsContextMenu)

After I changed the line to this (makes sense), everything's all good:
self.treeWidget.setContextMenuPolicy(Qt.CustomContextMenu)

Thanks to everyone who replied.

Christian


projetmbc wrote:

Christian Aubert a écrit :
I currently have a context menu for the whole QTreeWidget but I need 
finer-grained control on a per item basis. Has anyone implemented 
context menus for QTreeWidgetItems? Any pointers?


Christian

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



Hello,
here is a solution that works. I hope tha will help you.

To call the menu, just use :
   self.connect(self.treeWidget, 
QtCore.SIGNAL(customContextMenuRequested(const QPoint )), 
self.menuContextTree)


Here is the method menuContextTree :
  def menuContextTree(self, point):
# Infos about the node selected.
  index = self.treeWidget.indexAt(point)

  if not index.isValid():
 return

  item = self.treeWidget.itemAt(point)
  name = item.text(0)  # The text of the node.

# We build the menu.
  menu=QtGui.QMenu(self)
  action=menu.addAction(Souris au-dessus de)
  action=menu.addAction(name)
  menu.addSeparator()
  action_1=menu.addAction(Choix 1)
  action_2=menu.addAction(Choix 2)
  action_3=menu.addAction(Choix 3)

  print QtGui.QCursor.pos()
  menu.exec_(QtGui.QCursor.pos())



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


Re: [PyQt] How do you close a QDialog?

2009-04-09 Thread Demetrius Cassidy

I don't follow 100%, but I guess you have say a GameMainWindow (non Qt), and
you want to open a new QtDialog from within your MainWindow? 

The problem might be if you run your own even loop, then you run PyQt's
event loop, messages for your window are no longer being received, causing
the freeze. Since I don't know what your MainWindow is I can only haphazard
a guess.

Can you post a short sample reproducing the freeze? 


GatorAlli wrote:
 
 You see... I have a main application window. There is a button in the main
 window. Whan you click the button, the dialog should pop up. When the
 dialog's close command is called, I want the dialog to close cleanly,
 returning to the main window.
 
 I tried this...
 
 __Mainwindow.py
 import sprite
 import sys
 app = QtGui.QApplication(sys.argv)
 ui = sprite.action_select_dialog()
 ui.show()
 sys.exit(app.exec_())
 ___
 
 It opens the dialog perfectly, but when I call the hide command on the
 dialog, the dialog closes, but the main window is frozen. :-((
 
 That's all I want you to answer.
 
 
 
 
 
 

-- 
View this message in context: 
http://www.nabble.com/How-do-you-close-a-QDialog--tp22874235p22981747.html
Sent from the PyQt mailing list archive at Nabble.com.

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


Re: [PyQt] [PyQt 4.5] TypeError: pyqtBoundSignal cannot be converted to QObject in this context

2009-04-09 Thread Alexandr N Zamaraev

Phil Thompson wrote:

   def __connectAll(self):
 for dm in (self.__phys, self.__jur, self.__bus):
   dm.data_adds.connect(self.data_adds.emit)


I don't understand what you are trying to do in the last line.

It may well be more intuitive:
[code]
class DataLink(QtCore.QObject):
  data_adds = QtCore.QtCore.pyqtSignal(frozenset)
...
  def addObjects(self, objs):
obj_oids = self._internalAddObjects(objs, *args, **kwd)
self.data_adds.emit(obj_oids)
...
class DataPhys(DataLink): pass
class DataJur(DataLink): pass
class DataBus(DataLink): pass

class DataPerson(DataLink):
  __phys = None
  __jur = None
  __bus = None
  def __init__(self):
super(DataPerson, self, phys, jur, bus).__init__()
self.__phys = phys or DataPhys()
self.__jur = jur or DataJur()
self.__bus = bus or DatadBus()
self.__connectAll()

  def __connectAll(self):
for dm in (self.__phys, self.__jur, self.__bus):
  dm.data_adds.connect(self.data_adds.emit)
[/code]
I need to retransmit signals from the members.
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt