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 Update on Monday, May 27th 2025

[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
  • 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 9 May 2014, 10:07 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
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 9 May 2014, 10:13 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 9 May 2014, 12:54 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
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 9 May 2014, 20:34 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 10 May 2014, 16:11 last edited by
            #5

            Ok thank's.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 10 May 2014, 20:46 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

              1/6

              9 May 2014, 10:07

              • Login

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