Parameters in creating window



  • Hello. How i can transmit parameters in creating window

    class dialog:public QDialog
    {
        Q_OBJECT
    private:
        QLabel *label;
        QLabel *label1;
        QLabel *label2;
        QPushButton *ok_1;
        QPushButton *close_1;
        QLineEdit *LineEdit_1;
        QFrame *line_1;
    public:
        dialog(QWidget *parent=0, char answer); //like here new char parameter 
    private slots:
        void ok_clicked(char asnwer);
        void ok_enabled(QString);   
    }
    

  • Moderators

    @Eugene404 said in Parameters in creating window:

    dialog(QWidget *parent=0, char answer); //like here new char parameter

    default parameters can only be at the end of the parameter list. So switch position of your 2 parameters.



  • like this?

    class dialog:public QDialog
    {
        Q_OBJECT
    private:
        QLabel *label;
        QLabel *label1;
        QLabel *label2;
        QPushButton *ok_1;
        QPushButton *close_1;
        QLineEdit *LineEdit_1;
        QFrame *line_1;
    public:
        dialog(char answer,QWidget *parent=0);
    private slots:
        void ok_clicked(char asnwer);
        void ok_enabled(QString);
    };
    
    dialog::dialog(char answer,QWidget):public QDialog //constructor
    

    like this i have two errors

    1. prototype for 'dialog::dialog(char, QWidget)' does not match any in class 'dialog'
      dialog::dialog(char answer,QWidget):public QDialog
      ^
      2)candidates are: dialog::dialog(dialog&&)
      class dialog:public QDialog
      ^

  • Moderators

    @Eugene404
    spot the difference ;)

    dialog(char answer,QWidget *parent=0)
    
    dialog::dialog(char answer,QWidget)
    


  • @raven-worx

    dialog(char answer,QWidget *parent=0)
    dialog::dialog(char answer,QWidget *parent=0)
    

    like this ?


  • Moderators

    @Eugene404
    almost :)
    in the definition default parameters are not allowed. But yes, the missing pointer was what i meant.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.