[Qt-interest] How to close QMainWindow and open login dialog
David Boosalis
david.boosalis at gmail.com
Fri Aug 7 17:45:15 CEST 2009
Perhaps you can try making your toplevel class a windowless object.
Maybe just inheriting from QObject.
class MyAppClass public QObject
{
Q_OBJECT
public:
MyAppClass(QObject *parent = 0);
MyMainWindow *mainWIndow;
LoginWindow *loginWindow;
public slots:
void showLogin();
void showMain();
// or just have one slot - showWindow(int windowType);
};
You can connect or create the appropriate signals from MyMainWindow &
LoginWindow. For instances listening to QWidget::closeEvent();
If your doing this on Linux you can also use KUniqueApplication
instead ofQApplication, to make sure only one instance is running.
On Fri, Aug 7, 2009 at 7:25 AM, Aditya Sharma<88aditya88 at gmail.com> wrote:
> The problem goes like this,
> In an application I am building, I have one instance of LoginDialog
> inherited from QDialog. This takes username and password, if match is not
> found in the mysql database, the loginvalidate() returns 0. Return type of
> loginValidate of LoginDialog is used to determine whether or not to exit the
> program from the event loop in the main function. If match is found, program
> flow is as usual, opens the main window.
>
> Now here comes the problem. I have logout button in the QMainWindow
> inherited class. When it is clicked, private slot, logout() is called, in
> the logout() slot, i can write close() to close the current instance of
> QMainWindow, but how can I show to login dialog, Well, making a new object
> newlogin will help but still, slots in the LoginDialog won't call
> QMainWindow. What can I do.
>
> THank you in advance.
>
>
> Advance.
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
More information about the Qt-interest-old
mailing list