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. [solved]problem with variable member value and signals and slots connection
Forum Updated to NodeBB v4.3 + New Features

[solved]problem with variable member value and signals and slots connection

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 1.2k 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.
  • T Offline
    T Offline
    timain
    wrote on last edited by
    #1

    Hello, I have these two slots

    @void AjoutDefaut::beginProcess(QImage image)
    {
    m_currentAnomaly = ℑ
    auto n = m_currentAnomaly->width();
    m_btn_cont->setEnabled(true);
    //QImage currentImage = *(m_dragWidgetCible->m_currentAnomaly);
    connect(m_btn_cont, &QPushButton::clicked, this, &AjoutDefaut::startBorderDetect);
    }@

    m_currentAnomaly is a member variable of AjoutDefaut.
    m_currentNnomaly = &image works good (m_currentAnomaly is not NULL), but in the following slot, after connection with button click signal, compilater says that m_currentAnomaly points to NULL. I don't know what is the reason

    @void AjoutDefaut::startBorderDetect()
    {
    auto n = m_currentAnomaly->width(); CRASH HERE
    //m_dragWidgetCible->border_detect(*m_currentAnomaly);
    }@

    Thank you.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      m_currentAnomaly points to an invalid memory location. You are giving it the address of "image" which is only valid the time of beginProcess.

      Just use a QImage, it's an implicitly shared class.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • T Offline
        T Offline
        timain
        wrote on last edited by
        #3

        I replaced all variable points to QImage to QImage, It works now,
        Thank you for help SGaist.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Also

          @void AjoutDefaut::(const QImage& image)@

          use const references, no need copy the data multiple times

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • T Offline
            T Offline
            timain
            wrote on last edited by
            #5

            Ok thank's.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Since your problem is solved, please update the thread title prepending [solved] so other forum users may know a solution has been found :)

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              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