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. event connect not honoring default value of handler
Forum Updated to NodeBB v4.3 + New Features

event connect not honoring default value of handler

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 202 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.
  • R Offline
    R Offline
    RobbieP
    wrote on last edited by
    #1

    I have a button that I have tied to an event that has a default value. like so:

    here's the event:

    connect(gaugeDivisions1SpinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, &Window::divisions1Changed);
    

    here's the slot definition:

    private slots:
        void divisions1Changed(bool color = false);
    

    and here's the actual event code:

    void Window::divisions1Changed(bool Color)
    {
        QColor pColor = Qt::black;
        if (Color) pColor = getColor();
        renderArea->setDivisions1(gaugeDivisions1SpinBox->value(), gaugeDivisions1InnerRadiusSpinBox->value(), gaugeDivisions1OuterRadiusSpinBox->value(), gaugeDivisions1WidthSpinBox->value(), pColor);
    }
    

    When I click the spinbox, the Color bool value comes across as true. but if I call the event otherwise with no parameter...Color is correctly assumed false. What am I doing wrong? Anyone have any ideas?

    JonBJ 1 Reply Last reply
    0
    • R RobbieP

      I have a button that I have tied to an event that has a default value. like so:

      here's the event:

      connect(gaugeDivisions1SpinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, &Window::divisions1Changed);
      

      here's the slot definition:

      private slots:
          void divisions1Changed(bool color = false);
      

      and here's the actual event code:

      void Window::divisions1Changed(bool Color)
      {
          QColor pColor = Qt::black;
          if (Color) pColor = getColor();
          renderArea->setDivisions1(gaugeDivisions1SpinBox->value(), gaugeDivisions1InnerRadiusSpinBox->value(), gaugeDivisions1OuterRadiusSpinBox->value(), gaugeDivisions1WidthSpinBox->value(), pColor);
      }
      

      When I click the spinbox, the Color bool value comes across as true. but if I call the event otherwise with no parameter...Color is correctly assumed false. What am I doing wrong? Anyone have any ideas?

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

      @RobbieP said in event connect not honoring default value of handler:
      Signal void QSpinBox::valueChanged(int i) --- and your connect() to QOverload<int>::of(&QSpinBox::valueChanged) ---sends i as parameter, you let that through to your slot void divisions1Changed(bool color = false) as the value of color. Change your slot to match, or munch the i parameter in a lambda.

      1 Reply Last reply
      2

      • Login

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