PDA

View Full Version : How to create custom slot in Qt Designer 4.1?



jamadagni
6th January 2006, 03:32
I am using the Qt 3 Designer manual to do my first Qt program because Qt 4 manual does not have such a Quick Start. The Qt 3 manual tells me to

* Select calculatePushButton for the Sender, clicked() for the Signal, and ConversionForm for the Receiver.
* Click Edit Slots to invoke the Edit Functions dialog. Click New Function. Type over the Function name with the name of our new function: convert(), then click OK.
* Select convert() from the Slot combobox to complete our connection.

But I do not see any "Edit Slots" in the Qt 4 signal/slot editor. Where do I add this convert() slot?

Thanks.

sunil.thaha
6th January 2006, 04:17
No Way.
You cant Create custom slots like the one in Qt-3 ( using the designer ). When U subclass then u can add the custom slots yourself thereby eliminating the virtual funtions.

Hope you know that if u have a widget with signal - signal( param ). Then
a slot like on_widget_signal( param ) will connect the widget's signal to the slot

jamadagni
6th January 2006, 05:39
No Way. You cant Create custom slots like the one in Qt-3 ( using the designer ).
Ouch. I am totally new to Qt and C++ programming. (I knew a little C, but that was a long time ago. Isn't Qt 4 so friendly to start learning Qt?) I have submitted a bug to Trolltech asking them to give me us a Quick Start guide to Designer in Qt 4, but till then how do I learn Qt?

sunil.thaha
6th January 2006, 06:05
So U r a newbie ..
Welcome to the Team!

I hope you have installed the Qt. assistant ( the help ) if so
Click the Qt Reference Documentation Section . ( Only Click )
Nowclick the How to learn Qt (link)

Enjoy learning Qt.

If you are new to C++. Please find time to learn C++. The Tutorial section above gives links. and you can also use Google Ofcourse.

jamadagni
6th January 2006, 07:56
Welcome to the Team!
Thanks.

I hope you have installed the Qt. assistant
Yes of course I have. My problem is that I am trying to learn Qt and C++ at the same time as doing a new project for doing some astronomical calculations. That was how I learnt Visual Basic many years ago, while doing a custom accounts maintenance software for my father.

So I hope, with the help of the people here, I can learn Qt and C++ fairly well.

So can you please tell me whether the "portable C" code from the Swiss Ephemeris Code (1.2 MB) (ftp://ftp.astro.com/pub/swisseph/swe_unix_src_1.67.00.tar.gz) is implementable as is or as a library in Qt/C++?

vkhaitan
6th January 2006, 09:00
It is easy to learn qt and c++ in 15 days. I am saying so, because I had done it!!
The designer tutorial would be ulitmate helpful in this regard !

jamadagni
6th January 2006, 09:56
It is easy to learn qt and c++ in 15 days. I am saying so, because I had done it!! The designer tutorial would be ulitmate helpful in this regard !
It is good to hear that. But please tell: what programming languages were you previously in knowledge of?

Matt Smith
6th January 2006, 10:49
Ouch. I am totally new to Qt and C++ programming. (I knew a little C, but that was a long time ago. Isn't Qt 4 so friendly to start learning Qt?) I have submitted a bug to Trolltech asking them to give me us a Quick Start guide to Designer in Qt 4, but till then how do I learn Qt?

For learning Qt, there is a book called C++ GUI Programming with Qt 3, by J Blanchette & M Summerfield (Prentice Hall, 2004). It teaches all major aspects of Qt including the table and network modules. This might be a better step for a beginner than rushing straight into Qt 4 which so far is not well-documented other than for the reference documentation on the Trolltech website.

QtD4 is in my opinion a poor cousin for the Qt3 version, although some of its deficiencies have been made-up for in the 4.1 version - for example, there is a menu editor as there was in v3 and also an action editor. I still haven't found a way of adding actions to toolbars, though. And using Designer widgets in programs is nowhere near as simple as it was in Qt 3. For my project I'm using Qt 4.1 as by the time it's ready for use I suspect Qt and KDE 3 will both be obsolete, but Qt 3 right now is not obsolete and there may well be a greater body of experience out there in Qt 3 than Qt 4.

jens
7th January 2006, 13:51
You can add actions to toolbars by first creating an action in the action editor, and then drag them onto the toolbar of your choice. Unfortunately there is no way to drag widgets like spinners onto toolbars yet.

Regarding the Qt 3 book, it should be mentioned that it can be downloaded for free in PDF format here:
http://doc.trolltech.com/4.1/how-to-learn-qt.html

cioannou
8th January 2006, 12:33
Unfortunately after going through the Qt 4 docs many times haven't yet managed to add a custom slot.

The project uses:

main.cpp
simpleform.h
simpleform.cpp

What I am trying to do is include the .h file in simpleform.cpp and implement the custom slot in the .cpp file so just in case the form is changed I don't loose my changes because of uic.

If I copy and paste various examples, it seems to work. But not when designing my own form.

I use the CodeBlocks IDE (Just in case this could mean something)

jacek
8th January 2006, 15:19
What I am trying to do is include the .h file in simpleform.cpp and implement the custom slot in the .cpp file so just in case the form is changed I don't loose my changes because of uic.
Have you read this (http://doc.trolltech.com/4.1/designer-using-a-component.html) (personally I prefer the single inheritance approach)?

Matt Smith
8th January 2006, 15:30
Unfortunately after going through the Qt 4 docs many times haven't yet managed to add a custom slot.

The bottom line is, you cannot write slots in Qt 4 Designer. That functionality has been taken out, and the .ui.h file system abolished, in Qt 4. Qt4D does have a signal/slot editor, but that only applies to connecting existing signals to existing slots.

To use your forms in programs, you need to follow the instructions in the Qt Designer Manual (http://doc.trolltech.com/4.1/designer-manual.html), specifically the section towards the bottom headed "Using Forms and Components".

To see an example of what the manual calls "The Single Inheritance Approach", you might like to look at the source code to my in-process app, to be found at its Sourceforge CVS repository: http://cvs.sourceforge.net/viewcvs.py/catkin/catkin-qtm/. You need to look at both catkin.h and catkin.cc, and note the use of the Ui namespace and the object which is used to set up the user-interface of another object. Thus, widgets and other objects coming from Qt Designer are clearly marked in the catkin.cc source code.

For the direct approach, two examples can be found in the catkin.cc file at the same repository, in the about() and getPreferences() methods.

Hope this helps.

Matt Smith

cioannou
9th January 2006, 08:00
Thanks a lot for the info,

have already tried all methods mentioned in the docs, but they all failed, so I will check your example.

GreyGeek
11th January 2006, 04:27
Ouch. I am totally new to Qt and C++ programming. (I knew a little C, but that was a long time ago. Isn't Qt 4 so friendly to start learning Qt?) I have submitted a bug to Trolltech asking them to give me us a Quick Start guide to Designer in Qt 4, but till then how do I learn Qt?
Like you are trying to do, I learned both QT4 and C++ at the same time.
It's not that hard.
For example, you declare a slot in your app.h file:


private slots:
...
void searchAll();

Then you put a connection in the constructor of your app class, in app.cpp:


connect(ui.btnSearch, SIGNAL(clicked()), this, SLOT(searchAll()));

and, you put the function in app.cpp, outside the constuctor:


void app::searchAll() {
// user enters value to search for in search text box
....

cioannou
12th January 2006, 19:33
For example, you declare a slot in your app.h file:


private slots:
...
void searchAll();


That's exactly what I am trying to avoid.
If I change the app.h that is generated by the designer and afterwards add some new widgets to my dialog, all my private slots will be lost.

Am I missing something?

jacek
12th January 2006, 20:08
If I change the app.h that is generated by the designer and afterwards add some new widgets to my dialog, all my private slots will be lost.

Don't touch those files and instead create another class. You can find the exact instructions here (http://doc.trolltech.com/4.1/designer-using-a-component.html), but in short you need something like this:

#include <QDialog>
#include "ui_somedialog.h" // this file was made from somedialog.ui by uic

class SomeDialog : public QDialog
{
Q_OBJECT
public:
SomeDialog( QWidget *parent = 0 );

private slots:
void searchAll();

private:
Ui::SomeDialog _ui;
};

// .cpp file:

void SomeDialog( QWidget *parent ) : QDialog( parent )
{
_ui.setupUi( this );
// ...
}

void SomeDialog::searchAll()
{
// ...
}

GreyGeek
13th January 2006, 02:10
OK, here are some excepts of my Homestead app that do what I believe you want to do. This code throws up a dialog which contains a list of wholenames selected from a SQL select of type form "LIKE partialname%". Clicking on the proprty_id column and/or the ssn column selects that property or that individual. Clicking the OK or Cancel button closes the dialog.

Here is the wholenamedlg.h header file:


#ifndef WHOLENAMEDLG_H
#define WHOLENAMEDLG_H
.... snip includes ..........

#include "ui_wholenamedlg.h"


class wholenamedlg : public QDialog
{
Q_OBJECT

public:
wholenamedlg(QWidget *parent = 0, QString partName = "", QString strYear = "2006", QString strSpouseFlag = "F");
QString resultSSN;
QString resultPropID;
QTableView wholeNameView;

private:
Ui::wholeNameDlgUI wnui;

private slots:
void copyVALUES(const QModelIndex &);

};

#endif

"wholeNameDlgUI" is the name given to the dialog during the Designer session.


Here is the wholenamedlg.cpp file which displays the dialog grid:


/*
Program: wholenamedlg.cpp
Description: A dialog class for picking an SSN and/or a name out of
a query created by the SQL LIKE % syntax.
Author: Jerry L Kreps
Date: 11/10/05 - ff
*/

#include "wholenamedlg.h"
... snip includes ......

wholenamedlg::wholenamedlg(QWidget *parent, QString partName, QString strYear, QString strSpouseFlag)
: QDialog(parent)
{
wnui.setupUi(this);

connect(this->wnui.wholeNameView, SIGNAL(clicked(QModelIndex)), this, SLOT(copyVALUES( QModelIndex )));

partName.prepend("'");
partName.append("'");
QString queryStr = "SELECT proprty_id,ssn,wholename,sssn,sname,city,address FROM persinfo_";
queryStr.append(strYear);
if (strSpouseFlag == "F") {
queryStr.append(" WHERE wholename LIKE ");
queryStr.append(partName);
queryStr.append(" ORDER BY wholename");
} else {
queryStr.append(" WHERE sname LIKE ");
queryStr.append(partName);
queryStr.append(" ORDER BY sname");
}
QSqlQueryModel *viewModel = new QSqlQueryModel(wnui.wholeNameView);
viewModel->setHeaderData(0, Qt::Horizontal, "ID");
viewModel->setHeaderData(1, Qt::Horizontal, "SSN");
viewModel->setHeaderData(2, Qt::Horizontal, "WholeName");
viewModel->setHeaderData(3, Qt::Horizontal, "SSSN");
viewModel->setHeaderData(4, Qt::Horizontal, "SName");
viewModel->setHeaderData(5, Qt::Horizontal, "City");
viewModel->setHeaderData(6, Qt::Horizontal, "Address");

viewModel->setQuery(queryStr);
if (viewModel->lastError().type() == QSqlError::NoError){
wnui.wholeNameView->setModel(viewModel);
if (viewModel->rowCount() > 0){
for (int i = 0; i < viewModel->rowCount(); ++i)
this->wnui.wholeNameView->verticalHeader()->resizeSection(i,20);
for (int i = 0; i < 7; ++i)
wnui.wholeNameView->resizeColumnToContents(i);
}
}
}

void wholenamedlg::copyVALUES(const QModelIndex &QMI) {
QVariant value = this->wnui.wholeNameView->model()->data(QMI,0);
if (value.isValid()) {
if (QMI.column() == 0)
this->resultPropID = value.toString();
if (QMI.column() == 1)
this->resultSSN = value.toString();
}
}


"wholeNameView" is the name given in the Designer to the tableview grid containing the data being displayed.

Here is the main class for the homestead application. The segment shown displays that part of the searchALL() function which calls the wholenamedlg dialog.


/*
Program: homestead.cpp
Description: Homestead Application Program (HAP)
Author: Jerry L Kreps
Date: 11/1/2005
*/
#include "homestead.h"
#include "wholenamedlg.h"
...
homestead::homestead(QWidget *parent) : QMainWindow(parent) {
// homestead constructor method
ui.setupUi(this); // draw the gui interface
this->Year65 = 1940; // set birth year for 65 year olds
this->dbYear = "2006";
...

connect(ui.btnSearch, SIGNAL(clicked()), this, SLOT(searchAll()));
...
...
} // end of the homestead constructor

void homestead::searchAll() {
// user enters value to search for in search text box
// and clicks the radio button indicating its data type
// then clicks the search button
bool foundProp = false;
bool foundPers = false;
QString queryStr = "";
QString seekWN = "'"; // set up for possible wholename search
QString requestString;
requestString = "Searching for: ";
requestString.append(ui.leSearch->text()); // echo search request
if (ui.rbWholeName->isChecked()) {
QString partialName = ui.leSearch->text().trimmed();
if (partialName.contains('%')){
//select proprty_id,ssn,wholename,sssn,sname,city,address from persinfo_2006
//WHERE wholename LIKE 'MILLER/E%' ORDER BY wholename
wholenamedlg dlg(this, partialName, this->dbYear, "F");
if( dlg.exec() == QDialog::Accepted ){
QString strSSN = dlg.resultSSN.trimmed();
QString strPropID = dlg.resultPropID.trimmed();
// was ssn returned from dialog ?
.....
..... snip lot's of code .....
.....

Here is what the dialog looks like in action:
26

cioannou
14th January 2006, 14:23
Don't touch those files and instead create another class. You can find the exact instructions here (http://doc.trolltech.com/4.1/designer-using-a-component.html), but in short you need something like this:

#include <QDialog>
#include "ui_somedialog.h" // this file was made from somedialog.ui by uic

class SomeDialog : public QDialog
{
Q_OBJECT
public:
SomeDialog( QWidget *parent = 0 );

private slots:
void searchAll();
etc. etc etc
}


Ok , it's obvious that I am stupid and noob at the same time (in c++ & qt), so I can't be more embarassed.:confused: :(

here is my code:



#include <qapplication.h>
#include "ui_bullshit.h"

class bullshit : public QDialog
{
Q_OBJECT

public:
bullshit(QWidget *parent = 0);

private:
Ui::bullshit ui;
};


bullshit::bullshit( QWidget *parent )
{

ui.setupUi( this );

// ...
}


int main(int argc, char **argv)
{
QApplication app(argc, argv);

QDialog *window = new QDialog;
Ui::bullshit _ui;
_ui.setupUi(window);

window->show();
return app.exec();
}


If i compile main.cpp it's ok , but linker gives me a nice error:

main.cpp undefined reference to `vtable for bullshit'

I should not paste the errors I get when I use a separate .h and .cpp for the class constructor and functions.

jacek
14th January 2006, 17:18
main.cpp undefined reference to `vtable for bullshit'
Add:
#include "main.moc"at the end of main.cpp and run "qmake && make".

cioannou
15th January 2006, 18:46
Thanks a lot , it compiled && linked now, but still not working




#include <qapplication.h>
#include <qmessagebox.h>

#include "ui_bullshit.h"

class bullshit : public QDialog, private Ui::bullshit
{
Q_OBJECT
public:
bullshit(QWidget *parent = 0);
// private:
// Ui::bullshit ui;

private slots:
void msgbox();
void on_helloButton_clicked();
};



bullshit::bullshit( QWidget *parent ): QDialog(parent)
{
setupUi(this);

connect(helloButton,SIGNAL(clicked()),this,SLOT(ms gbox()));

}

void bullshit::msgbox()
{
QMessageBox::information(this, "Application name","The factory default will be used instead.");
}



void bullshit::on_helloButton_clicked()
{
QMessageBox::information(this, "Application name","The factory default will be used instead.");
}




Can you please explain why we included the .moc file?

Txs

jacek
15th January 2006, 21:30
Thanks a lot , it compiled && linked now, but still not working
What do you mean by "not working"? How does your main() function look like?


Can you please explain why we included the .moc file?
Because you have placed definition of a class with Q_OBJECT macro in .cpp file. You wouldn't have to do it, if that class definition wes in a header.

cioannou
15th January 2006, 22:14
What do you mean by "not working"? How does your main() function look like?




int main(int argc, char **argv)
{
QApplication app(argc, argv);

QDialog *window = new QDialog;
Ui::bullshit _ui;
_ui.setupUi(window);

window->show();
QMessageBox::information(window, "startup msgbox",
"The factory default will be used instead.");
return app.exec();
}


I mean that I press my helloButton but no QMessageBox appears.



Because you have placed definition of a class with Q_OBJECT macro in .cpp file. You wouldn't have to do it, if that class definition wes in a header.

Got it, thanks a lot.

jacek
15th January 2006, 22:23
I mean that I press my helloButton but no QMessageBox appears.
You don't instatiate your class anywhere.

Try:
int main( int argc, char **argv )
{
QApplication app(argc, argv);

bullshit *window = new bullshit();
window->show();

QMessageBox::information( window, "startup msgbox", "The factory default will be used instead." );
return app.exec();
}

PS. Please, next time choose a different name for your class.

cioannou
16th January 2006, 08:09
You don't instatiate your class anywhere.

Try:
int main( int argc, char **argv )
{
QApplication app(argc, argv);

mydialogclass *window = new mydialogclass();
window->show();

QMessageBox::information( window, "startup msgbox", "The factory default will be used instead." );
return app.exec();
}

PS. Please, next time choose a different name for your class.


Ooops. This was really noob.

Sorry for the class name, it just came out from my dissapointment.

Already 'renamed' it.

cioannou
16th January 2006, 20:14
:confused: I am sorry but it still doesn't work.:confused:

If I connect the button to an existing slot e.g. accept() then the button works.




#include <qapplication.h>
#include <qdialog.h>
#include <qmessagebox.h>
#include "ui_MyDialog.h"

class MyDialog : public QDialog
{
public:
MyDialog(QWidget *parent = 0);
private:
Ui::MyDialog ui;
private slots:
void msgbox();
};

MyDialog::MyDialog( QWidget *parent )
{
ui.setupUi(this);

connect(ui.helloButton,SIGNAL(clicked()),this,SLOT (msgbox()));
connect(ui.pressMe,SIGNAL(clicked()),this,SLOT(acc ept()));
}

void MyDialog::msgbox()
{
QMessageBox::information(0, "test","message");
}

int main(int argc, char **argv)
{
QApplication app(argc, argv);
MyDialog *window=new MyDialog;

window->show();
return app.exec();
}

jacek
16th January 2006, 20:22
:confused: I am sorry but it still doesn't work.
Because there is no Q_OBJECT macro, you need it if you define new signals or slots in your class.


class MyDialog : public QDialog
{
Q_OBJECT
public:
...
};

cioannou
16th January 2006, 20:44
OK guys , I got it!!!! :)

here it is:

mydialog.h


#include <qapplication.h>
#include <qdialog.h>
#include <qmessagebox.h>
#include "ui_MyDialog.h" //This is the header generated by uic Mydialog.ui > ui_MyDialog.h

class MyDialog : public QDialog
{
Q_OBJECT

public:
MyDialog(QWidget *parent = 0);
private:
Ui::MyDialog ui;
private slots:
void msgbox();
};


mydialog.cpp


#include "mydialog.h"

MyDialog::MyDialog( QWidget *parent )
{
ui.setupUi(this);

connect(ui.helloButton,SIGNAL(clicked()),this,SLOT (msgbox()));
connect(ui.pressMe,SIGNAL(clicked()),this,SLOT(acc ept()));
}

void MyDialog::msgbox()
{
QMessageBox::information(0, "test","message");
}


main.cpp


#include <qapplication.h>
#include <qdialog.h>
#include <qmessagebox.h>
#include "mydialog.h"

int main(int argc, char **argv)
{
QApplication app(argc, argv);
MyDialog *window=new MyDialog;

window->show();
return app.exec();
}


I still get an error concerning 'undefined reference to vtable for MyDialog' if I build inside Code::Blocks.

If I use:

qmake
mingw32-make

It works (finally!!!)

jacek
16th January 2006, 21:05
I still get an error concerning 'undefined reference to vtable for MyDialog' if I build inside Code::Blocks.

If I use:

qmake
mingw32-make

It works (finally!!!)
Every time you add or remove Q_OBJECT macro, you have to rerun qmake.

yop
16th January 2006, 21:27
I still get an error concerning 'undefined reference to vtable for MyDialog' if I build inside Code::Blocks.

Create a custom tool that runs qmake in your project and on the project options select "Using a custom makefile". Then you only have to run your tool every time you add a new file to the project and then just build with the outputed makefile. It's the same as typing it but you get it with a couple of clicks ;)

cioannou
17th January 2006, 08:03
Thanks for the info, I will try it.

I have now added a listbox to my dialog.

Can you point me to some docs about how to get a reference to that listbox and e.g. add some items?

Txs

GreyGeek
18th January 2006, 20:28
For learning Qt, there is a book called C++ GUI Programming with Qt 3, by J Blanchette & M Summerfield (Prentice Hall, 2004). It teaches all major aspects of Qt including the table and network modules. This might be a better step for a beginner than rushing straight into Qt 4 which so far is not well-documented other than for the reference documentation on the Trolltech website.

I first learned QT3 by using that book, and I really like the QT3 Designer, which was a "lite" GUI RAD for QT3. But, my biggest hurdle was trying to work with the way the Designer does things. And I ran into "generated code - do not modify" msgs just at the point that I needed to modify something to add my functionality. :(



QtD4 is in my opinion a poor cousin for the Qt3 version, although some of its deficiencies have been made-up for in the 4.1 version - for example, there is a menu editor as there was in v3 and also an action editor. I still haven't found a way of adding actions to toolbars, though. And using Designer widgets in programs is nowhere near as simple as it was in Qt 3. For my project I'm using Qt 4.1 as by the time it's ready for use I suspect Qt and KDE 3 will both be obsolete, but Qt 3 right now is not obsolete and there may well be a greater body of experience out there in Qt 3 than Qt 4.

As much as I liked the QT3 Designer, making the QT4 Designer JUST a GUI designer and nothing more was, as I came to appreciate, an excellent move, both for me, as a newbie to C++ and QT, and for Trolltech, too. IMO.

First, the QT4 Designer just creates graphical interfaces. Nothing more. This simplifies both the design and use of the Designer. Trolltech can refocus resources to their central product, the QT widget set, and let others worry about a GUI RAD tool, or making the designer a plugin for such a tool. I can concentrate on the basics of C++ programming, and QT is just another API. If you've learned Java then QT will be a snap.

Second, I can apply in a more straight forward manner the basic techniques of OOP programming using C++ and QT's API, and this approach is MUCH MORE flexible than trying to stuff every application into the QT3 Designer straightjacket. It was the Designer's way or the hiway. :( Once I stopped trying to figure out which combobox in the lower right hand panel I needed to create a QSqlQuery in, and just created my own in a class definition in a header file I was time and money ahead of the old way. Adding dialogs, for example, is easy. One dialog.h file to define your dialog class, and one dialog.ui file to create the interface. After that it takes only a couple of lines to call the dialog in your app.cpp.

here is "dlglogin.h"


#ifndef DLGLOGIN_H
#define DLGLOGIN_H
#include "ui_dlglogin.h"

class dlgLogin : public QDialog
{
Q_OBJECT

public:
Ui::dlgLoginUi dui;
dlgLogin()
{
// called with 'dlgLogin dlg'. Only ID and password required
dui.setupUi(this);
dui.leUserName->setText("your revid");
dui.leUserPassword->setText("");
dui.leUserName->setFocus();
dui.leUserName->selectAll();
}
};

#endif



Below is a jpg of the dlglogin ui file that you can see shows the connections as well. The ObjectName of the dialog.ui is dlgLoginUi, which is why you see the line


Ui::dlgLoginUi dui;


For completeness here is the main.cpp file that calls the login dialog before it executes the ht application



int main( int argc, char * argv[] ) {
QString strRejected = "";
QApplication app(argc, argv);
app.setQuitOnLastWindowClosed(false);
dlgLogin dlg;
if( dlg.exec() == QDialog::Accepted ){
QSqlDatabase hapdb = QSqlDatabase::addDatabase(DBDRIVER);
hapdb.setHostName(DBHOST);
hapdb.setDatabaseName(DBNAME);
hapdb.setUserName(dlg.dui.leUserName->text());
hapdb.setPassword(dlg.dui.leUserPassword->text());
if ( hapdb.open() ) {
homestead ht;
ht.RevID = dlg.dui.leUserName->text();
ht.show();
app.setQuitOnLastWindowClosed(true);
return app.exec();
} else {
strRejected = QString("The Login was rejected because: %1").arg(hapdb.lastError().text()).toLatin1();
QMessageBox::information(0,"Login Rejected!",strRejected,
QMessageBox::Ok,QMessageBox::NoButton,QMessageBox: :NoButton);
return 1;
}
} else {
strRejected = QString("User Canceled the login!").toLatin1();
QMessageBox::information(0,"Login Rejected!",strRejected,
QMessageBox::Ok,QMessageBox::NoButton,QMessageBox: :NoButton);
return 2;
}
}




Lastly, just about everything I read about C++ programming applies to programming with QT as well. I can forget about using the designer to create anything but my *.ui files.:D
47

GreyGeek
18th January 2006, 20:46
That's exactly what I am trying to avoid.
If I change the app.h that is generated by the designer and afterwards add some new widgets to my dialog, all my private slots will be lost.

Am I missing something?
Yes. I am refering to app.h ... NOT app.ui or the ui_app.h file which the MOC creates.

The app.h file ISN'T generated by the designer. It's created by you!

In QT4 all the designer program does is create your ui interfaces. Any signal/slot connections you create with it apply only to the form itself or those objects that you placed on the form as you design your gui. You cannot use the designer to connect to a signal or slot which is not among those the designer adds itself to your ui. Ergo, you must create your own classes and add your external signals and slots to compliment the ui you design.

When I first switched to QT4 and left the QT3 Designer behind I was, at first, bewildered because I had learned how to make connections between objects, in the ui or out, strictly with the designer. It actually crippled me as far as learning how to OOP program using C++. Jacek was right. I am glad I hadn't burned the QT3 Designer habits as deeply into my 65 year old brain as long use of it would have done.