[Qgis-developer] Every pop-up displayed double on widget plugin

Tim Sutton tim at linfiniti.com
Thu Nov 9 12:09:32 EST 2006


Hi

Im not sure if this will help your problem at all buy why not use the
new autoconnect mechanism of qt4. Since you seem to be using the
multiple inheritance approach to implementing your dialogs anyway...

Once apon a time in a galaxy far away I wrote this:

http://qgis.org/content/view/81/65/

Which sort of explains it a bit....then you can get rid of this kind of stuff:

       // signals/slots mechanism in action
       connect( pbnDBConn, SIGNAL( clicked() ), this,
SLOT( on_pbnDBConn_clicked() ) );
       connect( pbLocate, SIGNAL( clicked() ), this,
SLOT( on_pbLocate_clicked() ) );

In fact I am almost certain if you just delete the above lines your
problem will go away since you are using the implicit slot naming
convention of qt autoconnect they will almost certainly cause your
double popup issue...

Hope that helps

Groete...

Tim

On 11/9/06, Schalk Snyman <snymans at wbs.co.za> wrote:
> Hi everyone!
>
> I know this is way off the topics discussed lately by QGIS developers
> and perhaps not even a QGIS-specific question, but I would really
> appreciate any insight.
>
> Overview:
> I have created a QGIS plugin with two widgets, using the plugin
> template: i.e. 1 plugin menu item with two menu items. The first widget
> is a simple 1-layer layout with a push-button, all in 1 group box. The
> second widget has three group boxes and two separate buttons. The one
> button opens another widget (with text box inputs and a save button) and
> the other button starts an algorithm.
>
> The problem:
> The first widget works fine, the second, however, displays everything
> double (error->dialog boxes(another on OK), button->the widget(x2)
> etc.). The gui part for both widgets is logically similar and I have not
> any gui objects repeated in my *.ui file.
>
> I have included the more important code at the bottom of e-mail...
>
> Please, I have a final project demo next Wednesday!
>
> Schalk
>
> Code
> -----
> Plugin(.cpp):
>
> #include "importer.h"
> #include "localise.h"
>
> void GSMLocator::initGui()
> {
>
>   // Create the action for tool
>   mQImportPointer = new QAction(QIcon("plugin.png"),tr("&Import
> drive-tests"), this);
>   mQLocatePointer = new QAction(QIcon("plugin.png"),tr("&Locate GSM
> cellphones"), this);
>   // Set the what's this text
>   mQImportPointer->setWhatsThis(tr("Plugin that supports the import of
> Ericsson TEMS format drive-tests."));
>   mQLocatePointer->setWhatsThis(tr("Plugin that provides GSM positioning
> functionality from measurement reports."));
>   // Connect the action to the run
>   connect(mQImportPointer, SIGNAL(activated()), this,
> SLOT(runImport()));
>   connect(mQLocatePointer, SIGNAL(activated()), this,
> SLOT(runLocate()));
>   // Add the toolbar
>   //mToolBarPointer = new QToolBar((QMainWindow *) mQGisApp, "&GSM
> Locate Tools");
>   //mToolBarPointer->setLabel("&GSM Locate Tools");
>
>   // Add to the toolbar
>   mQGisIface->addToolBarIcon(mQImportPointer);void GSMLocator::initGui()
> {
>
>   // Create the action for tool
>   mQImportPointer = new QAction(QIcon("plugin.png"),tr("&Import
> drive-tests"), this);
>   mQLocatePointer = new QAction(QIcon("plugin.png"),tr("&Locate GSM
> cellphones"), this);
>   // Set the what's this text
>   mQImportPointer->setWhatsThis(tr("Plugin that supports the import of
> Ericsson TEMS format drive-tests."));
>   mQLocatePointer->setWhatsThis(tr("Plugin that provides GSM positioning
> functionality from measurement reports."));
>   // Connect the action to the run
>   connect(mQImportPointer, SIGNAL(activated()), this,
> SLOT(runImport()));
>   connect(mQLocatePointer, SIGNAL(activated()), this,
> SLOT(runLocate()));
>   // Add the toolbar
>   //mToolBarPointer = new QToolBar((QMainWindow *) mQGisApp, "&GSM
> Locate Tools");
>   //mToolBarPointer->setLabel("&GSM Locate Tools");
>
>   // Add to the toolbar
>   mQGisIface->addToolBarIcon(mQImportPointer);
>   mQGisIface->addToolBarIcon(mQLocatePointer);
>   mQGisIface->addPluginMenu("&GSM Locate Tools", mQImportPointer);
>   mQGisIface->addPluginMenu("&GSM Locate Tools", mQLocatePointer);
> }
>
>   mQGisIface->addToolBarIcon(mQLocatePointer);
>   mQGisIface->addPluginMenu("&GSM Locate Tools", mQImportPointer);
>   mQGisIface->addPluginMenu("&GSM Locate Tools", mQLocatePointer);
> }
>
> void GSMLocator::runImport()
> {
>   Importer *imp = new Importer(mQGisApp, QgisGui::ModalDialogFlags);
>   imp->show();
> }
>
> void GSMLocator::runLocate()
> {
>   Localise *local = new Localise(mQGisApp, QgisGui::ModalDialogFlags);
>   local->show();
> }
> -----------------------------------------------------------------------------------------------------------------
> Widget1 [works correctly]
> -------(.h)
> class Importer : public QWidget, private Ui::ImportDrive
> {
>         Q_OBJECT
>
> public:
>         Importer(QWidget *parent = 0, Qt::WFlags fl = 0 );
>         ~Importer();
>
> public slots:
>         int pressed_lPushbutton();
>         void on_pbnbuttFile_clicked();
> .....(.cpp)............................................
>
> #include <QtGui>
> #include "importer.h"
>
> Importer::Importer(QWidget *parent, Qt::WFlags fl )
> {
>         setupUi(this); // this sets up GUI
>
>         // signals/slots mechanism in action
>         connect( pushButton_lnew, SIGNAL( clicked() ), this,
> SLOT( pressed_lPushbutton() ) );
> connect(this,SIGNAL( nextRecord(int) ),progressBar,SLOT( setValue(int) ) );
>         connect( butt_File, SIGNAL( clicked() ), this,
> SLOT( on_pbnbuttFile_clicked() ) );
>
> }
>
> Importer::~Importer()
> {
> }
>
> void Importer::on_pbnbuttFile_clicked() {
>   QString myFileNameQString =
>     QFileDialog::getOpenFileName(this, //parent dialog
>                                  tr("Select filename of drive-test list (drive-tests must be in same
> folder)"),
>                  ".", //initial dir
>                                  tr("Text file (*.txt *.fmt)"));
>   txtFile->setText(myFileNameQString);
> }
> --------------------------------------------------------------------------------------------------------
> Widget2
> --------(.h)
> // Qt functions
> #include "ui_LocateGSM.h"
> #include "configconn.h"
> #include <QtGui>
>
> class Localise : public QWidget, private Ui::LocateGSM
> {
>         Q_OBJECT
>
> public:
>         Localise(QWidget *parent = 0, Qt::WFlags fl = 0 );
>         ~Localise();
>         char* join(char* s1, char* s2);
>
> ..........(.cpp)....................................................
>
> #include <QtGui>
> #include "localise.h"
>
> Localise::Localise(QWidget *parent, Qt::WFlags fl )
> {
>         setupUi(this); // this sets up GUI
>
>         // signals/slots mechanism in action
>         connect( pbnDBConn, SIGNAL( clicked() ), this,
> SLOT( on_pbnDBConn_clicked() ) );
>         connect( pbLocate, SIGNAL( clicked() ), this,
> SLOT( on_pbLocate_clicked() ) );
>
>         // enabling/disabling buttons
>         //pushButton_stopnew->setEnabled( false );
> }
>
> Localise::~Localise()
> {
> }
>
> void Localise::on_pbnDBConn_clicked()
> {
>         ConfigConn *conninfo = new ConfigConn(this);
>         conninfo->show();
> }
> --------------------------------END--------------------------------------------------------------
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.qgis.org
> http://lists.qgis.org/cgi-bin/mailman/listinfo/qgis-developer
>


-- 
-- 
Tim Sutton

Visit http://qgis.org for a great Open Source GIS
Home Page: http://linfiniti.com
Skype: timlinux
MSN: tim_bdworld at msn.com
Yahoo: tim_bdworld at yahoo.com
Jabber: timlinux
Irc: timlinux on #qgis at freenode.net



More information about the Qgis-developer mailing list