Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Please help me with easy problems. How to connect(//)
Forum Updated to NodeBB v4.3 + New Features

Please help me with easy problems. How to connect(//)

Scheduled Pinned Locked Moved General and Desktop
13 Posts 3 Posters 3.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    arnolddumas
    wrote on 30 Mar 2013, 10:00 last edited by
    #4

    Ok, now I see your problem :

    @
    OboiCalc::OboiCalc(QWidget* parent) : QWidget(parent)
    {
    connect(error, SIGNAL(isVisible(bool)), this, SLOT(setDisabled(bool)));
    }
    @

    error should be a pointer to a QDialog.

    @
    class OboiCalc : public QWidget
    {
    private :

    QDialog* error;
    

    }
    @

    This should work fine now

    1 Reply Last reply
    0
    • F Offline
      F Offline
      freelife
      wrote on 30 Mar 2013, 10:07 last edited by
      #5

      but I use here "&", as in another connects, which work very well.
      @connect(error.pushButton, SIGNAL(clicked()), &error, SLOT(hide()));
      connect(error.pushButton_2, SIGNAL(clicked()), &error, SLOT(hide ()));@
      It is compiled, but SLOT(setDisabled) of OboiCalc doesn't work.

      1 Reply Last reply
      0
      • F Offline
        F Offline
        freelife
        wrote on 30 Mar 2013, 10:18 last edited by
        #6

        I made error as a pointer to a QDialog and added -> to all methods, but program exited with code -1073741819.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SetBetterPass
          wrote on 30 Mar 2013, 10:29 last edited by
          #7

          Which slot doesn't work?
          You should put something like qDebug()<<"in slot"; at first line of slot (don't forget include QDebug) to see if the problem is with connect or in slot code, if you won't get "in slot" in application output after you call slot the problem is with connecting. Try it and if you won't find the problem by yourself post code.
          And to your error, have you created the object? Add this line to your code if not: @ error=new QDialog(this);@ where you need to create the dialog.

          1 Reply Last reply
          0
          • F Offline
            F Offline
            freelife
            wrote on 30 Mar 2013, 10:52 last edited by
            #8

            "This is sourse":https://docviewer.yandex.ru/?url=ya-disk:///disk/Oboi.rar&name=Oboi.rar&c=5156c2610790
            click at" Скачать оригинал " on the top.
            Then if you click at first button("Счет") the window chould setDisable, but it shouldn't. This is problem.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SetBetterPass
              wrote on 30 Mar 2013, 11:08 last edited by
              #9

              please post your code here(just the part with issue), I can't speak/read Russian well and it wants me to log in to see the code, I am not going to create account^^

              1 Reply Last reply
              0
              • F Offline
                F Offline
                freelife
                wrote on 30 Mar 2013, 15:10 last edited by
                #10

                Sorry I did't know, what you must have accaunt to download)
                Look at calc.cpp.
                @//calc.h
                #ifndef CALC_H
                #define CALC_H
                #include <QDialog>
                #include "ui_OboiCalc.h"
                #include <Error.h>

                class OboiCalc : public QWidget, public Ui::OboiCalc
                {
                Q_OBJECT
                public:
                OboiCalc(QWidget *parent = 0);
                private:
                Error1 error;
                protected slots:
                void setValue();
                void clearCalc();
                };

                #endif // CALC_H
                @
                @//Error.h
                #ifndef ERROR_H
                #define ERROR_H
                #include <QDialog>
                #include "ui_Error1.h"

                class Error1 : public QDialog, public Ui::Error1
                {
                Q_OBJECT
                public:
                Error1(QWidget parent = 0);
                };
                #endif // ERROR_H
                @
                @//calc.cpp
                #include <QtGui>
                #include "Calc.h"
                #include <Error.h>
                OboiCalc::OboiCalc(QWidget parent):QWidget(parent)
                {
                setupUi(this);
                spinBox2_3->setDisabled(true);
                //
                **********************************
                connect(&error, SIGNAL(isVisible(bool)), this, SLOT(setDisabled(bool)));//This connect doesn't work =(
                //************************************
                connect(buttonOk, SIGNAL(clicked()), this, SLOT(setValue()));
                connect(buttonClear, SIGNAL(clicked()), this, SLOT(clearCalc()));
                connect(error.pushButton, SIGNAL(clicked()), &error, SLOT(hide()));
                connect(error.pushButton_2, SIGNAL(clicked()), &error, SLOT(hide ()));
                connect(error.pushButton_2, SIGNAL(clicked()), this, SLOT(clearCalc()));
                connect(checkBox, SIGNAL(clicked(bool)), spinBox2_3, SLOT(setEnabled(bool)));

                }
                void OboiCalc::clearCalc()
                {
                //something
                }
                void OboiCalc::setValue()//вывод
                {
                //something
                error.show();

                }
                @
                @//error.cpp
                #include <QtGui>
                #include <Calc.h>
                #include <Error.h>
                Error1::Error1(QWidget *parent): QDialog(parent)
                {
                setupUi(this);

                }
                @

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SetBetterPass
                  wrote on 30 Mar 2013, 16:20 last edited by
                  #11

                  actually you haven't created object error so you cant connect it.
                  You should connect these 2 buttons in error.cpp in constructor, so from this:
                  @
                  connect(error.pushButton, SIGNAL(clicked()), &error, SLOT(hide()));
                  connect(error.pushButton_2, SIGNAL(clicked()), &error, SLOT(hide ()));
                  @
                  make this: @
                  Error1::Error1(QWidget *parent): QDialog(parent)
                  {
                  setupUi(this);
                  connect(pushButton, SIGNAL(clicked()), this, SLOT(hide()));
                  connect(pushButton_2, SIGNAL(clicked()), this, SLOT(hide ()));

                  }@
                  Don't forget create slots before debugging (at least empty) or you get errors.

                  and to connect these 2:
                  @
                  connect(error.pushButton_2, SIGNAL(clicked()), this, SLOT(clearCalc()));
                  connect(&error, SIGNAL(isVisible(bool)), this, SLOT(setDisabled(bool)));
                  @
                  you have to have created object:
                  @
                  //in constructor or somewhere:
                  connect(something,SIGNAL(someSignal()),this,SLOT(errorMessage()));
                  @
                  make slot that creates error message
                  @
                  void OboiCalc::errorMessage(){
                  Error1* error = new Error1(this);
                  connect(error->pushButton_2, SIGNAL(clicked()), this, SLOT(clearCalc()));
                  connect(error, SIGNAL(isVisible(bool)), this, SLOT(setDisabled(bool)));
                  error->show();
                  }
                  @

                  1 Reply Last reply
                  0
                  • F Offline
                    F Offline
                    freelife
                    wrote on 30 Mar 2013, 17:52 last edited by
                    #12

                    Thank you! I understood)

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      SetBetterPass
                      wrote on 30 Mar 2013, 19:48 last edited by
                      #13

                      No problem, ask more if you there is something you need to help with, otherwise mark thread [Solved] (edit post and add [Solved] to title). :)

                      1 Reply Last reply
                      0

                      13/13

                      30 Mar 2013, 19:48

                      • Login

                      • Login or register to search.
                      13 out of 13
                      • First post
                        13/13
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved