Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. connect Not working when widget is disabled

connect Not working when widget is disabled

Scheduled Pinned Locked Moved Unsolved Qt 6
3 Posts 2 Posters 508 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
    Gaetano03
    wrote on last edited by
    #1

    Hello,

    I am a newbie to Qt, sorry if this might seem trivial.

    I am trying to connect two custom widgets on the main window constructor, namely wHead and wpicostepper with the following line

    connect(wHead,SIGNAL(enable_view(bool)),wpicostepper,SLOT(enable_all(bool)));

    The line is basically enabling and disabling the wpicostepper widget on the basis of the signal emitted from wHead (checkbox checked or not)
    In particular the SIGNAL of wHead is emitted through the following method

    void test_def_widget::on_checkBox_10MHz_clicked()
    {
    emit enable_view(ui->checkBox_10MHz->isChecked());
    }

    implemented in wHead as a private slot

    Everything works fine if I don't start with the wpicostepper disabled.

    However if I add the following line

    wpicostepper->setDisabled(true)

    in the mainwindow constructor (as I want the widget to start as disabled and enable it once the checkbox is pressed), the connect seems not to work anymore.

    Could you please help me understanding what's going on?

    Thanks a lot

    jsulmJ 1 Reply Last reply
    0
    • G Gaetano03

      Hello,

      I am a newbie to Qt, sorry if this might seem trivial.

      I am trying to connect two custom widgets on the main window constructor, namely wHead and wpicostepper with the following line

      connect(wHead,SIGNAL(enable_view(bool)),wpicostepper,SLOT(enable_all(bool)));

      The line is basically enabling and disabling the wpicostepper widget on the basis of the signal emitted from wHead (checkbox checked or not)
      In particular the SIGNAL of wHead is emitted through the following method

      void test_def_widget::on_checkBox_10MHz_clicked()
      {
      emit enable_view(ui->checkBox_10MHz->isChecked());
      }

      implemented in wHead as a private slot

      Everything works fine if I don't start with the wpicostepper disabled.

      However if I add the following line

      wpicostepper->setDisabled(true)

      in the mainwindow constructor (as I want the widget to start as disabled and enable it once the checkbox is pressed), the connect seems not to work anymore.

      Could you please help me understanding what's going on?

      Thanks a lot

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Gaetano03 said in connect Not working when widget is disabled:

      the connect seems not to work anymore

      I'm sure connect itself works. You can verify this adding a debug output in the slot.
      What probably happens is that disabled widget is not updated. But I don't know what you are doing in the slot.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • G Offline
        G Offline
        Gaetano03
        wrote on last edited by
        #3

        Thanks, you are right,

        the problem was that in the slot I was enabling/disabling a subwidget of wpicostepper, while with wpicostepper->setDisabled I am disabling everything

        1 Reply Last reply
        0

        • Login

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