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. Pushbutton crashed.

Pushbutton crashed.

Scheduled Pinned Locked Moved Solved General and Desktop
c++ qt
26 Posts 5 Posters 3.9k Views
  • 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.
  • G Offline
    G Offline
    Gutks
    wrote on last edited by Gutks
    #1

    I'm a beginner, and I want button_clicked(). add and remove in lineEdit (). But the code I made is crashing.

    #include "test.h"  /  #include "ui_test.h"   /   #include "QMouseEvent"
    int value1= 0; int value2= 0; int value3= 0; int value4= 0;
    
    Test::Test(QWidget *parent) : QMainWindow(parent) , ui(new Ui::Test){
        ui->setupUi(this);
        ui->lineEdit1->setEnabled(false);
        ui->lineEdit2->setEnabled(false);
    
    }
    
    Test::~Test(){delete ui;}
    void Test::on_button1_clicked(){
        QMouseEvent *p= nullptr;
       if(p->button()==Qt::LeftButton){ui->lineEdit1->setText(QString::number(value1++));}
        else{if(p->button()==Qt::RightButton){ui->lineEdit1->setText(QString::number(value1--));}}
    }
    
    void Test::on_button2_clicked(){
        QMouseEvent *p= nullptr;
       if(p->button()==Qt::LeftButton){ui->lineEdit2->setText(QString::number(value2++));}
        else{if(p->button()==Qt::RightButton){ui->lineEdit2->setText(QString::number(value2--));}}
    }
    

    I tried to redeploy the tutorial code: https://forum.qt.io/topic/101957/check-if-button-was-right-clicked-or-left-clicked/11

    class CustomPushButton : public QPushButton{
        Q_OBJECT
    public:
        CustomPushButton(QWidget *parent = nullptr);
    
    protected:
       void	mousePressEvent(QMouseEvent *e) override;
       void mouseReleaseEvent(QMouseEvent *e) override;
    
    signals:
        void leftClicked();
        void rightClicked();
    };
    

    however I am confused if I connect leftclicked () with on_button1_clicked (); or if connect leftclicked()
    inside on_button1_clicked () that will check, where will send the value to lineEdit().
    This makes a simple check into a complex one in events... Can someone help me?

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Gutks said in Pushbutton crashed.:

      QMouseEvent *p= nullptr;
      if(p->button()==Qt::LeftButton){ui->lineEdit1->setText(QString::number(value1++));}

      and you really expect that this will not crash? Dereferencing a nullptr will for sure not work - c++ basics.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      G 1 Reply Last reply
      4
      • Christian EhrlicherC Christian Ehrlicher

        @Gutks said in Pushbutton crashed.:

        QMouseEvent *p= nullptr;
        if(p->button()==Qt::LeftButton){ui->lineEdit1->setText(QString::number(value1++));}

        and you really expect that this will not crash? Dereferencing a nullptr will for sure not work - c++ basics.

        G Offline
        G Offline
        Gutks
        wrote on last edited by
        #3

        @Christian-Ehrlicher Thanks for correcting, it worked here.

        Did not enter the block (if) and did not assign value in lineEdit(). Test using hitButton() to return pointer mouse, erro. ;--;

        QMouseEvent *e;
            if(hitButton(e->pos())==Qt::LeftButton){ui->lineEdit1->setText(QString::number(value1++));}}
        

        There is a way to check without using CONNECT()?
        How to CONNECT() would be like this?

        connect(ui->pushButton(),connect(leftClicked()),this,SLOT(mousePressEvent()));
        connect(ui->pushButton(),connect(rightClicked()),this,SLOT(mousePressEvent()));
        
        Object::connect No such signal Qpushbutton::rightClicked() 
        
        Pl45m4P 1 Reply Last reply
        0
        • G Gutks

          @Christian-Ehrlicher Thanks for correcting, it worked here.

          Did not enter the block (if) and did not assign value in lineEdit(). Test using hitButton() to return pointer mouse, erro. ;--;

          QMouseEvent *e;
              if(hitButton(e->pos())==Qt::LeftButton){ui->lineEdit1->setText(QString::number(value1++));}}
          

          There is a way to check without using CONNECT()?
          How to CONNECT() would be like this?

          connect(ui->pushButton(),connect(leftClicked()),this,SLOT(mousePressEvent()));
          connect(ui->pushButton(),connect(rightClicked()),this,SLOT(mousePressEvent()));
          
          Object::connect No such signal Qpushbutton::rightClicked() 
          
          Pl45m4P Offline
          Pl45m4P Offline
          Pl45m4
          wrote on last edited by Pl45m4
          #4

          @Gutks said in Pushbutton crashed.:

          connect(ui->pushButton(),connect(leftClicked()),this,SLOT(mousePressEvent()));

          This cant work either.

          What is ui->pushButton() in your case? () indicates a function... Does it return your unique instance of your CustomPushButton class? I dont think so :)

          2nd param must be SIGNAL(leftClicked()).
          In addition, I dont think that mousePressEvent is a slot, you can connect to.

          Edit:

          Where do you create the instances of your Pushbutton class? Would be helpful if you show your test.cpp and CustomPushButton.cpp

          Edit_2:

          Your signal definitions in your button class are correct. Now you need to emit them in your pushButton's mouseClickEvent/ mouseReleaseEvent (according to you logic). Inside your implementation of these two, you put your check, which mouse key was actually used. THEN you emit the corresponding signal.

          Inside your test widget class, where your pushButtons are placed, you make the standard connection to setup what will happen, if your button is clicked with left or right mouse key... (Two different slots for your actions)

          Something like:
          connect(pushbutton1, SIGNAL(leftClicked()), this, SLOT (btnLeftClicked()));

          And this slot is the place, where you put your code to increase your counter (lineEdit) or do something else.

          Edit_3:

          Are your value vars global variables? Better put them in your test header as member vars.


          If debugging is the process of removing software bugs, then programming must be the process of putting them in.

          ~E. W. Dijkstra

          1 Reply Last reply
          2
          • G Offline
            G Offline
            Gutks
            wrote on last edited by Gutks
            #5

            @Pl45m4 said in Pushbutton crashed.:

            Thanks for responding and sorry for the delay.

            Pl45m4: "What is ui->pushButton() in your case?" - And I typed it wrong, thanks for correcting. ui->pushButton1.

            CustomPushButton.cpp, I tried to use macro const Q_Q(QAbstractButton),
            error: use of undeclared identifier 'q_func'.

            Not being able to access the emitPressed() and emitRelease(), class scope QAbstractButton.

            So my mousePressEvent and mouseReleaseEvent, stayed like this:
            customushbutton.cpp

            #include "custompushbutton.h"
            
            CustomPushButton::CustomPushButton(QWidget *parent){}
            void CustomPushButton::mousePressEvent(QMouseEvent *e){
                QAbstractButton *p;
                if(e->button()==Qt::LeftButton){p->click();emit pressed();}
                else{if(e->button()==Qt::RightButton){p->click();emit pressed();}else{e->ignore();return;}}
            }
            
            void CustomPushButton::mouseReleaseEvent(QMouseEvent *e){
                QAbstractButton *p;
                //Q_Q(QAbstractButton);
                if(e->button()==Qt::LeftButton){p->click();emit pressed();}
                else{if(e->button()==Qt::RightButton){p->click();emit pressed();}else{e->ignore();return;}}
            }
            

            test.cpp

            #include "test.h"
            #include "ui_test.h"
            #include "QMouseEvent"
            
            int value1= 0;
            int value2= 0;
            int value3= 0;
            int value4= 0;
            
            Test::Test(QWidget *parent) : QMainWindow(parent) , ui(new Ui::Test){
                ui->setupUi(this);
                ui->lineEdit1->setEnabled(false);
                ui->lineEdit2->setEnabled(false);
            
                connect(ui->button1, SIGNAL(leftClicked()) , this, SLOT(btnLeftClicked()))   ;
                connect(ui->button1, SIGNAL(rightClicked()), this, SLOT (btnRightClecked())) ;
            
                connect(ui->button2, SIGNAL(leftClicked()) , this, SLOT(btnLeftClicked()))   ;
                connect(ui->button2, SIGNAL(rightClicked()), this, SLOT(btnRightClicked()))  ;
            }
            

            QObject::connect: No such signal QPushButton::leftClicked()
            The connect and increment should be inside the on_button_clicked()?

            Yes, I put it as global, to facilitate the test. If I did it as a member of the class (seters and geters),

            I would have work to get the value of the line edit and convert string to number, and so do the increment
            and decrement.

            Pl45m4P 1 Reply Last reply
            0
            • G Gutks

              @Pl45m4 said in Pushbutton crashed.:

              Thanks for responding and sorry for the delay.

              Pl45m4: "What is ui->pushButton() in your case?" - And I typed it wrong, thanks for correcting. ui->pushButton1.

              CustomPushButton.cpp, I tried to use macro const Q_Q(QAbstractButton),
              error: use of undeclared identifier 'q_func'.

              Not being able to access the emitPressed() and emitRelease(), class scope QAbstractButton.

              So my mousePressEvent and mouseReleaseEvent, stayed like this:
              customushbutton.cpp

              #include "custompushbutton.h"
              
              CustomPushButton::CustomPushButton(QWidget *parent){}
              void CustomPushButton::mousePressEvent(QMouseEvent *e){
                  QAbstractButton *p;
                  if(e->button()==Qt::LeftButton){p->click();emit pressed();}
                  else{if(e->button()==Qt::RightButton){p->click();emit pressed();}else{e->ignore();return;}}
              }
              
              void CustomPushButton::mouseReleaseEvent(QMouseEvent *e){
                  QAbstractButton *p;
                  //Q_Q(QAbstractButton);
                  if(e->button()==Qt::LeftButton){p->click();emit pressed();}
                  else{if(e->button()==Qt::RightButton){p->click();emit pressed();}else{e->ignore();return;}}
              }
              

              test.cpp

              #include "test.h"
              #include "ui_test.h"
              #include "QMouseEvent"
              
              int value1= 0;
              int value2= 0;
              int value3= 0;
              int value4= 0;
              
              Test::Test(QWidget *parent) : QMainWindow(parent) , ui(new Ui::Test){
                  ui->setupUi(this);
                  ui->lineEdit1->setEnabled(false);
                  ui->lineEdit2->setEnabled(false);
              
                  connect(ui->button1, SIGNAL(leftClicked()) , this, SLOT(btnLeftClicked()))   ;
                  connect(ui->button1, SIGNAL(rightClicked()), this, SLOT (btnRightClecked())) ;
              
                  connect(ui->button2, SIGNAL(leftClicked()) , this, SLOT(btnLeftClicked()))   ;
                  connect(ui->button2, SIGNAL(rightClicked()), this, SLOT(btnRightClicked()))  ;
              }
              

              QObject::connect: No such signal QPushButton::leftClicked()
              The connect and increment should be inside the on_button_clicked()?

              Yes, I put it as global, to facilitate the test. If I did it as a member of the class (seters and geters),

              I would have work to get the value of the line edit and convert string to number, and so do the increment
              and decrement.

              Pl45m4P Offline
              Pl45m4P Offline
              Pl45m4
              wrote on last edited by Pl45m4
              #6

              @Gutks said in Pushbutton crashed.:

              Not being able to access the emitPressed() and emitRelease(), class scope QAbstractButton.

              Why not? Your own pushbutton class inherits QPushbutton and you have added some signals on your own... Just emit these.
              (emit pressed() is the wrong signal after all. You named you signals in your button class differenta and these are the ones, you need to use inside your mouse event)

              And again my question :)
              Where do you create (new) your button instances button1 and button2?
              ui->button1 only works, if you've created your button with QtDesigner (or if they are part of your ui_classname.h at least).

              Edit:

              Do you make use of widget promotion? If yes, it may work like this, but if you don't, you'll need to instantiate your buttons first, in order to connect something to them.

              @Gutks said in Pushbutton crashed.:

              QObject::connect: No such signal QPushButton::leftClicked()

              This indicates, that your ui->button1 is currently not your custom button. I would say, these are still pointers to your basic QPushButtons.
              Read about "Promoting Widgets in Qt" (Link) or create your CustomPushbuttons by code and add them to you layout manually.

              Your QAbstractButton *p inside your mouseEvents also does nothing and is not necessary. What do you expect from doing this? :)

              @Gutks said in Pushbutton crashed.:

              I would have work to get the value of the line edit and convert string to number, and so do the increment
              and decrement.

              No, you dont. Only if you want to access these values from "outside". If you use them only their own class, you dont need getter / setter. In addition, you could make use of signals & slots to change the values, but if these are just counters, you dont even need to do that.


              If debugging is the process of removing software bugs, then programming must be the process of putting them in.

              ~E. W. Dijkstra

              G 1 Reply Last reply
              1
              • Pl45m4P Pl45m4

                @Gutks said in Pushbutton crashed.:

                Not being able to access the emitPressed() and emitRelease(), class scope QAbstractButton.

                Why not? Your own pushbutton class inherits QPushbutton and you have added some signals on your own... Just emit these.
                (emit pressed() is the wrong signal after all. You named you signals in your button class differenta and these are the ones, you need to use inside your mouse event)

                And again my question :)
                Where do you create (new) your button instances button1 and button2?
                ui->button1 only works, if you've created your button with QtDesigner (or if they are part of your ui_classname.h at least).

                Edit:

                Do you make use of widget promotion? If yes, it may work like this, but if you don't, you'll need to instantiate your buttons first, in order to connect something to them.

                @Gutks said in Pushbutton crashed.:

                QObject::connect: No such signal QPushButton::leftClicked()

                This indicates, that your ui->button1 is currently not your custom button. I would say, these are still pointers to your basic QPushButtons.
                Read about "Promoting Widgets in Qt" (Link) or create your CustomPushbuttons by code and add them to you layout manually.

                Your QAbstractButton *p inside your mouseEvents also does nothing and is not necessary. What do you expect from doing this? :)

                @Gutks said in Pushbutton crashed.:

                I would have work to get the value of the line edit and convert string to number, and so do the increment
                and decrement.

                No, you dont. Only if you want to access these values from "outside". If you use them only their own class, you dont need getter / setter. In addition, you could make use of signals & slots to change the values, but if these are just counters, you dont even need to do that.

                G Offline
                G Offline
                Gutks
                wrote on last edited by
                #7

                @Pl45m4

                NameProjet= Test;
                classe1= customPushButton.h ; customPushButton;
                Classe2= test.h ; test.cpp = ( Widget, ui->classe)
                other= main.cpp;

                I tried to use this logic similar to the previous tutorial, however, Macro ( Q_Q() ),
                it is not stated, when I try to instantiate q->emitPressed(). return error: use of undeclared identifier 'q_func';

                I tried to change the 'Q' for 'D' ( Q_D), equal to the situation below, returns another.
                error: cannot initialize a variable of type 'QAbstractButtonPrivate *const' with an rvalue of type 'QPushButtonPrivate'
                Q_D(Class)

                void QAbstractButton::mousePressEvent(QMouseEvent *e){
                    Q_D(QAbstractButton);
                    if (e->button() != Qt::LeftButton) {
                        e->ignore();
                        return;
                    }
                    if (hitButton(e->pos())) {
                        setDown(true);
                        d->pressed = true;
                        repaint();
                        d->emitPressed();
                        e->accept();
                    } else {
                        e->ignore();
                    }
                }
                

                Ok, I'm going to make the right sign and study the custom widgets with Qt Designer. Thank you for the patience, using google translation . I return with possible results or errors.

                JonBJ 1 Reply Last reply
                0
                • G Gutks

                  @Pl45m4

                  NameProjet= Test;
                  classe1= customPushButton.h ; customPushButton;
                  Classe2= test.h ; test.cpp = ( Widget, ui->classe)
                  other= main.cpp;

                  I tried to use this logic similar to the previous tutorial, however, Macro ( Q_Q() ),
                  it is not stated, when I try to instantiate q->emitPressed(). return error: use of undeclared identifier 'q_func';

                  I tried to change the 'Q' for 'D' ( Q_D), equal to the situation below, returns another.
                  error: cannot initialize a variable of type 'QAbstractButtonPrivate *const' with an rvalue of type 'QPushButtonPrivate'
                  Q_D(Class)

                  void QAbstractButton::mousePressEvent(QMouseEvent *e){
                      Q_D(QAbstractButton);
                      if (e->button() != Qt::LeftButton) {
                          e->ignore();
                          return;
                      }
                      if (hitButton(e->pos())) {
                          setDown(true);
                          d->pressed = true;
                          repaint();
                          d->emitPressed();
                          e->accept();
                      } else {
                          e->ignore();
                      }
                  }
                  

                  Ok, I'm going to make the right sign and study the custom widgets with Qt Designer. Thank you for the patience, using google translation . I return with possible results or errors.

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by JonB
                  #8

                  @Gutks
                  Especially if you are a beginner, why are you trying to use macros like Q_D() and Q_Q() at all? So far as I know they are for internal Qt code. I have never used them in any user code I have written, why do you think you need them?

                  G 1 Reply Last reply
                  3
                  • JonBJ JonB

                    @Gutks
                    Especially if you are a beginner, why are you trying to use macros like Q_D() and Q_Q() at all? So far as I know they are for internal Qt code. I have never used them in any user code I have written, why do you think you need them?

                    G Offline
                    G Offline
                    Gutks
                    wrote on last edited by Gutks
                    #9

                    @JonB In order to instantiate: emitPressed(); emitRelease(); equal example
                    of the QAbstractButton class.

                    Pablo J. RoginaP JonBJ 2 Replies Last reply
                    0
                    • G Gutks

                      @JonB In order to instantiate: emitPressed(); emitRelease(); equal example
                      of the QAbstractButton class.

                      Pablo J. RoginaP Offline
                      Pablo J. RoginaP Offline
                      Pablo J. Rogina
                      wrote on last edited by
                      #10

                      @Gutks said in Pushbutton crashed.:

                      instantiate: emitPressed(); emitRelease();

                      Mmm, strange that you need to "instantiate" what seems to be signals...

                      Upvote the answer(s) that helped you solve the issue
                      Use "Topic Tools" button to mark your post as Solved
                      Add screenshots via postimage.org
                      Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                      1 Reply Last reply
                      2
                      • G Gutks

                        @JonB In order to instantiate: emitPressed(); emitRelease(); equal example
                        of the QAbstractButton class.

                        JonBJ Offline
                        JonBJ Offline
                        JonB
                        wrote on last edited by JonB
                        #11

                        @Gutks
                        Yes, but why are you doing so, given that emitPressed() is not documented and private to the innards of QAbstractButton? Which is why you are running into the compilation errors.... My question is: why are trying to do anything like this? The fact that it's in QAbstractButtonPrivate should give you a clue.

                        G 1 Reply Last reply
                        1
                        • JonBJ JonB

                          @Gutks
                          Yes, but why are you doing so, given that emitPressed() is not documented and private to the innards of QAbstractButton? Which is why you are running into the compilation errors.... My question is: why are trying to do anything like this? The fact that it's in QAbstractButtonPrivate should give you a clue.

                          G Offline
                          G Offline
                          Gutks
                          wrote on last edited by
                          #12

                          @JonB

                          The implementation of this function is accessing Q_D, since I am re-implementing it, I thought I could do the same.

                          void QAbstractButton::mousePressEvent(QMouseEvent *e)
                          

                          I will study the qt designer, to try to solve, otherwise, I will create an Auxiliary button to remove in the edit line. I think it's simpler than using events

                          JonBJ 1 Reply Last reply
                          0
                          • G Gutks

                            @JonB

                            The implementation of this function is accessing Q_D, since I am re-implementing it, I thought I could do the same.

                            void QAbstractButton::mousePressEvent(QMouseEvent *e)
                            

                            I will study the qt designer, to try to solve, otherwise, I will create an Auxiliary button to remove in the edit line. I think it's simpler than using events

                            JonBJ Offline
                            JonBJ Offline
                            JonB
                            wrote on last edited by
                            #13

                            @Gutks
                            But why are you "re-implementing" it at all? Usually a user class sub-classes, not re-implements. Re-implementing is fraught, e.g. what happens if the internals change over time. Since you say "I'm a beginner" I cannot see why you would want to do such a thing, when 99.9% of other users do not.

                            I keep saying the same thing, so I'll leave it to you now.

                            G 1 Reply Last reply
                            2
                            • JonBJ JonB

                              @Gutks
                              But why are you "re-implementing" it at all? Usually a user class sub-classes, not re-implements. Re-implementing is fraught, e.g. what happens if the internals change over time. Since you say "I'm a beginner" I cannot see why you would want to do such a thing, when 99.9% of other users do not.

                              I keep saying the same thing, so I'll leave it to you now.

                              G Offline
                              G Offline
                              Gutks
                              wrote on last edited by
                              #14

                              @JonB
                              Okay, thanks for trying to help. I will search for a solution to my problem.

                              Pl45m4P JonBJ Pablo J. RoginaP 5 Replies Last reply
                              0
                              • G Gutks

                                @JonB
                                Okay, thanks for trying to help. I will search for a solution to my problem.

                                Pl45m4P Offline
                                Pl45m4P Offline
                                Pl45m4
                                wrote on last edited by
                                #15

                                @Gutks

                                I already gave you an almost step by step manual how to solve your problem... You dont need Q_Q or reimplement any signals.


                                If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                                ~E. W. Dijkstra

                                1 Reply Last reply
                                2
                                • G Gutks

                                  @JonB
                                  Okay, thanks for trying to help. I will search for a solution to my problem.

                                  JonBJ Offline
                                  JonBJ Offline
                                  JonB
                                  wrote on last edited by
                                  #16

                                  @Gutks
                                  Both @Pl45m4 & I are trying to say you don't need to go down the route you are on....

                                  1 Reply Last reply
                                  1
                                  • G Gutks

                                    @JonB
                                    Okay, thanks for trying to help. I will search for a solution to my problem.

                                    Pablo J. RoginaP Offline
                                    Pablo J. RoginaP Offline
                                    Pablo J. Rogina
                                    wrote on last edited by
                                    #17

                                    @Gutks said in Pushbutton crashed.:

                                    if(p->button()==Qt::LeftButton){ui->lineEdit1->setText(QString::number(value1++));}
                                    
                                    else{if(p->button()==Qt::RightButton){ui->lineEdit1->setText(QString::number(value1--));}
                                    

                                    From your requirements it's apparent you need a custom QPushButton that extends existing one by adding just the rightclicked() signal, and nothing else. So you'll have both signals (existing left click) and new one (right click) to connect as you wish.

                                    Please take a look at this SO question & answers.

                                    Upvote the answer(s) that helped you solve the issue
                                    Use "Topic Tools" button to mark your post as Solved
                                    Add screenshots via postimage.org
                                    Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                                    1 Reply Last reply
                                    2
                                    • G Gutks

                                      @JonB
                                      Okay, thanks for trying to help. I will search for a solution to my problem.

                                      JonBJ Offline
                                      JonBJ Offline
                                      JonB
                                      wrote on last edited by JonB
                                      #18

                                      @Gutks
                                      If what @Pablo-J-Rogina has discerned is correct --- you just want a left-/right-click to increment/decrement a number in a QLineEdit, is that right? --- then you would be better just using a QSpinBox, which is for entering numbers, and you wouldn't have any of this.....

                                      Pablo J. RoginaP 1 Reply Last reply
                                      1
                                      • JonBJ JonB

                                        @Gutks
                                        If what @Pablo-J-Rogina has discerned is correct --- you just want a left-/right-click to increment/decrement a number in a QLineEdit, is that right? --- then you would be better just using a QSpinBox, which is for entering numbers, and you wouldn't have any of this.....

                                        Pablo J. RoginaP Offline
                                        Pablo J. RoginaP Offline
                                        Pablo J. Rogina
                                        wrote on last edited by
                                        #19

                                        @JonB said in Pushbutton crashed.:

                                        then you would be better just using a QSpinBox,

                                        I think the goal here is the rightclicked() signal, what you connect that to is not relevant at this point

                                        Upvote the answer(s) that helped you solve the issue
                                        Use "Topic Tools" button to mark your post as Solved
                                        Add screenshots via postimage.org
                                        Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                                        JonBJ 1 Reply Last reply
                                        3
                                        • Pablo J. RoginaP Pablo J. Rogina

                                          @JonB said in Pushbutton crashed.:

                                          then you would be better just using a QSpinBox,

                                          I think the goal here is the rightclicked() signal, what you connect that to is not relevant at this point

                                          JonBJ Offline
                                          JonBJ Offline
                                          JonB
                                          wrote on last edited by JonB
                                          #20

                                          @Pablo-J-Rogina
                                          Oh, I see. You may be right. Or it just might turn out the user was going to use a left-/-right-click on a button to inc/dec a number, you never know... :)

                                          On a different tone, it's "unusual" to have the user right-click on a button. Possible, but possibly not intuitive. A "rocker" pushbutton (click at left/right for different behaviour, but with left mouse) might be another possibility.

                                          Pl45m4P 1 Reply Last reply
                                          1

                                          • Login

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