Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-interest Archive, November 2006
Lock up with QPopupMenu and QFileDialog


Message 1 in thread

Mac OS X 10.4, Qt 3.3.6:

In one of my apps a QPopupMenu item is bound to a QAction which  
invokes QFileDialog::getSaveFileName().  If I use the menu as a  
context menu, then when I select the menu item my app displays the  
file save dialog -- and locks up.

When invoked from the app's menu bar, the same action works fine.

Is this a known problem?  Is there a workaround?

Thanks for any help.  More info available on request.

///////////////////////////////////////////////////////////////////////
// From mainwin.ui.h:

void mainwin::init() {
     m_popup = new QPopupMenu(this);
     menuSaveAction->addTo(m_popup);
}

void mainwin::doSave() {
     QString filename = QFileDialog::getSaveFileName(
             "foo.txt", "Text Files (*.txt)", this,
             "Save Dialog", "Save File");
}

void mainwin::contextMenuEvent(QContextMenuEvent *) {
     m_popup->exec(QCursor::pos());
}

///////////////////////////////////////////////////////////////////////
// From mainwin.ui:
<actions>
     <action>
         <property name="name">
             <cstring>menuSaveAction</cstring>
         </property>
         <property name="text">
             <string>Save...</string>
         </property>
         <property name="menuText">
             <string>Save...</string>
         </property>
     </action>
</actions>

<connections>
     <connection>
         <sender>menuSaveAction</sender>
         <signal>activated()</signal>
         <receiver>mainwin</receiver>
         <slot>doSave()</slot>
     </connection>
</connections>

--
 [ signature omitted ]