Results 1 to 13 of 13

Thread: I am working on a POS project

  1. #1
    Join Date
    Apr 2014
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default I am working on a POS project

    I am totally new to qt. For the administration menu i have few options.What i want is when ever i trigger any menu field option one new window popup should come.To which i can use lineEdit ,labels and push button.That popup should also be connected with the database.I do not want to use designer form class because i have many field to go with.So it is not a good idea to add several designer form class.

    void MainWindow:n_actionChange_password_triggered()
    {
    }
    It would be helpful with anyone will write the code for the trigger event which will popup a dialog window.In the dialog window i want to use lineEdit ,label and push button .So that i could change the password .That popupwindow should also be connected with database.

    NOTE :- I do not want to use designer form class,for the purpose as i have so many popup to go with.


    Thanks in advance

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: I am working on a POS project

    Whether you use designer or code to create a dialog doesn't affect showing the dialogs:

    you create an instance of the class and then call show() for a modeless dialog or exec() for a modal dialog.

    My recommendation would be to use designer, especially since you are new to Qt.
    Even for experiences Qt developers it is usually a waste of time to write many lines of C++ code that can be autotically derived from an interactively modifyable visualisation.

    Cheers,
    _

  3. #3
    Join Date
    Apr 2014
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: I am working on a POS project

    Thanks for the reply.
    The think is that i want to use the code like this
    void MainWindow:n_actionChange_password_triggered()
    {
    QObject::connect(ui->actionChange_password,SIGNAL(triggered()),dialog, SLOT(show()));
    }
    to create popupwindow on each triggered field.I do not want to add designer form class for each field.Pls help me with the code it self.
    Thanks once again.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: I am working on a POS project

    I am afraid I don't understand.

    Not wanting to use designer for the thing it is good at aside, are the following assumptions correct?

    You have some QAction instances in your main window?
    And you want different dialogs to show for each of them?
    And each action should only show a single instance of "its" dialog?

    Cheers,
    _

  5. #5
    Join Date
    Apr 2014
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: I am working on a POS project

    Yes your assumption is right.
    I am helping u with my all codes.
    -------------
    mainwindow.h
    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    #include <QMainWindow>
    #include <QtDebug>
    #include <QFileInfo>
    namespace Ui {
    class MainWindow;
    }

    class MainWindow : public QMainWindow
    {
    Q_OBJECT

    public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

    private slots:
    void on_actionChange_password_triggered();
    public:
    Ui::MainWindow *ui;
    };

    #endif // MAINWINDOW_H


    -------------
    main.cpp
    --------------
    include "mainwindow.h"
    #include <QApplication>

    #include <QApplication>
    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    return a.exec();
    }


    --------------------

    mainwindow.cpp

    --------------------
    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include<QDialog>
    #include<qdialog.h>
    #include <QLibrary>
    #include <QtGui>
    #include <QTextEdit>


    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);
    }

    MainWindow::~MainWindow()
    {
    delete ui;
    }

    void MainWindow:n_actionChange_password_triggered() // change password field,refer to figure attach.In Fig have adminstration have
    // submenu for those sub menu popup should come
    {

    QObject::connect(ui->actionChange_password,SIGNAL(triggered()),QDialog ,SLOT(show()));

    }


    in the line : QObject::connect(ui->actionChange_password,SIGNAL(triggered()),QDialog ,SLOT(show()));

    i want to have the code which will create popup window for change password in this case.As i do not want to add one extra designer form class because there are so many field like add user,remove user,update user.I want to have separate popup for for each menu content (it should be like if i click on change password a new popup should be there) .So that i can use lineEdit and other options with window popup.If possible help me with code.I am tired trying
    Thanks
    Attached Images Attached Images
    Last edited by foxrider; 13th April 2014 at 21:24.

  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: I am working on a POS project

    I am not sure what your intention with the connect is, other than it obviously being wrong in syntax.

    The action is already connected to that very slot.

    Just create an instance of your password change dialog and show it (this will open multiple dialogs if the action is triggered multiple times)
    Qt Code:
    1. void MainWindow::on_actionChange_password_triggered()
    2. {
    3. // assumes PasswordChangeDialog deletes itself when being closed
    4. PasswordChangeDialog *dialog = new PasswordChangeDialog(this);
    5. dialog->show();
    6. }
    To copy to clipboard, switch view to plain text mode 

    Keep the instance if you only want one.
    Qt Code:
    1. void MainWindow::on_actionChange_password_triggered()
    2. {
    3. if (m_passwordChangeDialog == 0) {
    4. m_passwordChangeDialog = new PasswordChangeDialog(this);
    5. }
    6. m_passwordChangeDialog->show();
    7. m_passwordChangeDialog->raise();
    8. m_passwordChangeDialog->activateWindow();
    9. }
    To copy to clipboard, switch view to plain text mode 

    Use exec() if it should be modal.
    Qt Code:
    1. void MainWindow::on_actionChange_password_triggered()
    2. {
    3. PasswordChangeDialog dialog(this);
    4. dialog.exec();
    5. }
    To copy to clipboard, switch view to plain text mode 

    Whether you use designer for password change dialog or code it manually is really irrelevant to its usage. Manually coding it is way more work of course.

    Cheers,
    _

  7. #7
    Join Date
    Apr 2014
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: I am working on a POS project

    Thanks for the consideration once again.
    I am sorry for late reply.
    As i tried compiling with your posted code.I am getting the errors.Please refer to the screen shot.user login4.jpg.
    I am unable to guess that what is causing the errors.
    Help me
    Thanks !!!

    Note;- I have not changed any files code it is same as i had posted above.

  8. #8
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: I am working on a POS project

    Well, the compiler rightfully complains about you using a type (class) that it does not know about (PasswordChangeDialog).

    Add such a class to your project and include its header in mainwindow.cpp

    C++ might sometimes feel like magic, but it is not

    Cheers,
    _

  9. #9
    Join Date
    Apr 2014
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: I am working on a POS project

    Please help me with the code.I do not know where to declare the class and how to use it.
    Thanks

  10. #10
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: I am working on a POS project

    Creating a new class is really one of the most basic things in C++.
    You'll have to look at least a bit into C++ before you can start creating applications in C++.

    There are a lot of C++ beginner tutorials available on the web,

    Cheers,
    _

  11. #11
    Join Date
    Apr 2014
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: I am working on a POS project

    Quote Originally Posted by anda_skoa View Post
    Creating a new class is really one of the most basic things in C++.
    You'll have to look at least a bit into C++ before you can start creating applications in C++.

    There are a lot of C++ beginner tutorials available on the web,

    Cheers,
    _
    Well now i have some elementary knowledge of creating object and classes.Now i have created a class PasswordChangeDialog in mainwindow.h file and i have included this header file to mainwindow.cpp. Here is my mainwindow.h file
    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    #include <QMainWindow>
    #include <QtDebug>
    #include <QFileInfo>
    namespace Ui {
    class MainWindow;
    }

    class PasswordChangeDialog
    {

    };

    class MainWindow : public QMainWindow
    {
    Q_OBJECT

    public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

    private slots:
    void on_actionChange_password_triggered();
    public:
    Ui::MainWindow *ui;
    //MyDialog *mDialog;

    };

    #endif // MAINWINDOW_H


    Case 1. Now when i am running the code i am getting the error as shown in the screen shotuser login6.jpg

    Case 2. When i am trying to pass the reference of object (change) to pointer i am getting error as shown in the shotuser login7.jpg


    NOTE :- It is your wish to consider case 2.I tried it while i was learning pointer and object.You can continue with case 1.

    I am afraid now what to do.Help !!!
    Thanks
    Attached Images Attached Images

  12. #12
    Join Date
    Oct 2013
    Posts
    41
    Thanks
    1
    Thanked 8 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: I am working on a POS project

    Well your class PasswordChangeDialog has no constructor. It also has no function called show. What is it you think this class you are creating is supposed to do?

    It sounds like you want this class to inherit from QDialog. But judging from the difficulties you are having I would recommend finding a tutorial on creating popup dialogs.

  13. #13
    Join Date
    Apr 2014
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: I am working on a POS project

    Thanks a lot Mr anda_skoa and sulliwk06. Actually i was trying to inherit QDialog class without declearing it.I am able to do it now.

Similar Threads

  1. Replies: 1
    Last Post: 1st December 2013, 21:27
  2. Replies: 1
    Last Post: 8th February 2012, 06:09
  3. javascript loop not working in qml project
    By vinayaka in forum Qt Quick
    Replies: 1
    Last Post: 18th August 2011, 10:01
  4. Qt Creator Breakpoings in my shared library project not working
    By Lendrick in forum Qt Tools
    Replies: 1
    Last Post: 26th September 2010, 19:31
  5. Replies: 1
    Last Post: 4th December 2009, 00:34

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.