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

Schalk Snyman snymans at wbs.co.za
Thu Nov 9 11:23:18 EST 2006


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--------------------------------------------------------------



More information about the Qgis-developer mailing list