PDA

View Full Version : setup ui doesnt work or any of my mistake??



kurrachow
27th March 2011, 14:02
hi , i have a program , in which i made a menu ,called tools and connected the action to a slot which doesnt work .......


here is my project please chk this out.............61586159616061616162

Zlatomir
27th March 2011, 14:29
Is void MainWindow::execShowSettings() declared as a slot in the MainWindow class declaration?
//i assume that execShowSettings() is the slot that doesn't get called...

Also that you posted code that is not relevant for your problem (like settings.uiand some other Gui class), wouldn't be easier for all of us if you post only the code that is not working and tell us more information about how is not working? (like it give error at compile or at run-time, or the function/slot is not called, Creator display warnings, etc)

kurrachow
27th March 2011, 15:21
ok I have a private slot called execShowSettings().

i connected a action to the execShowSettings().

the execShowSettings() goes like this.

SettingsDialog dialog;
dialog.show();


the SettingsDialog class is defined in settings.h like this.



#ifndef SETTINGS_H
#define SETTINGS_H

#include <QtCore>
#include <QtGui>
#include "ui_settings.h"

#include "defs.h"
#include "gui.h"

class SettingsDialog : public Gui::Dialog , private Ui::Niranjan
{
Q_OBJECT


Gui::EngineButton *settingsButton;



public:
SettingsDialog(QWidget *parent = 0);
virtual ~SettingsDialog() {}


};


#endif // SETTINGS_H


the settings.cpp goes like this.....


#include "settings.h"


SettingsDialog::SettingsDialog(QWidget *parent) : Gui::Dialog(Gui::Dialog::CenterOfScreen,parent)
{
setupUi(this);
setWindowTitle(qApp->applicationName() + " " + qApp->applicationVersion() +
" - " + tr("Settings") + " ");


settingsButton = new Gui::EngineButton(tr("Settings"),sbToolbar);
settingsButton->setChecked(true);


sbToolbar->setExclusive(true);
sbToolbar->insertButton(0,settingsButton,0);
connect(sbToolbar,SIGNAL(buttonClicked(int)),swMai n,SLOT(setCurrentIndex(int)));


swMain->setCurrentIndex(0);
}

Zlatomir
27th March 2011, 15:28
And are there any errors? If yes are they at compile, or at run-time.
Qt Creator display any warnings about the signal/slot in Application output?
How exactly is not working?

LE: the problem is that you don't show the Settings dialog, here:


void MainWindow::execShowSettings()
{

SettingsDialog dialog; //you just create the object...

//you need to call exec() for a modal dialog
dialog.exec();

//or show() for non-modal, but for non-modal you need to create the object on the heap (using pointer and new)
}

See this FAQ (http://www.qtcentre.org/faq.php?faq=qt_general_category#faq_qt_designer_2f orms)