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. I can't access the variable in the structure from within the class
Qt 6.11 is out! See what's new in the release blog

I can't access the variable in the structure from within the class

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

    While I can read/write the 'mSepetler' variable from the three methods I marked in the picture, why can't I read/write from the method I marked in red?
    image.png

    jsulmJ 1 Reply Last reply
    0
    • M mamoo

      While I can read/write the 'mSepetler' variable from the three methods I marked in the picture, why can't I read/write from the method I marked in red?
      image.png

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

      @mamoo said in I can't access the variable in the structure from within the class:

      why can't I read/write from the method I marked in red?

      What happens if you try? How is that method implemented?

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

      M 1 Reply Last reply
      0
      • jsulmJ jsulm

        @mamoo said in I can't access the variable in the structure from within the class:

        why can't I read/write from the method I marked in red?

        What happens if you try? How is that method implemented?

        M Offline
        M Offline
        mamoo
        wrote on last edited by
        #3

        @jsulm Ekran görüntüsü_2023-02-15_17-19-43.png

        jsulmJ 1 Reply Last reply
        0
        • M mamoo

          @jsulm Ekran görüntüsü_2023-02-15_17-19-43.png

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

          @mamoo Please post code as text, not screen shots!
          You also did not say what happens! So, again: what happens (any error messages?)?

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

          M 1 Reply Last reply
          0
          • jsulmJ jsulm

            @mamoo Please post code as text, not screen shots!
            You also did not say what happens! So, again: what happens (any error messages?)?

            M Offline
            M Offline
            mamoo
            wrote on last edited by
            #5

            @jsulm I translate from google translate because my english is almost non-existent. I am sorry. it doesn't give any error message. it just reads my array variable 'mSepetler' as empty. However, I can read/write in 3 methods that I marked in the first picture I took.

            void SepetYonetimi::sepetiSat(const int pSepetIndex, const int pKullaniciID, const int pSatilanCariID, const double pOdenenTutar)
            {
                QString FaturaNo = yeniFaturaNo();
                //yeni fatura bilgisi girme başlangıcı
                sorgu.prepare("INSERT INTO faturalar (id, fatura_no, cari, tipi, tarih, kullanici, toplamtutar, odenentutar, kalantutar, odemetipi) "
                                "VALUES (nextval('faturalar_sequence'), ?, ?, ?, ?, ?, ?, ?, ?, ?)");
                sorgu.bindValue(0, FaturaNo);
                sorgu.bindValue(1, pSatilanCariID);
                sorgu.bindValue(2, 2);// 2 = satış faturası (veritabanında faturatipleri.tip)
                sorgu.bindValue(3, QDateTime::currentDateTime());
                sorgu.bindValue(4, pKullaniciID);
                sorgu.bindValue(5, mSepetler[pSepetIndex].toplamTutar); // sepet toplam tutarı
            
                qDebug() << mSepetler[pSepetIndex].toplamTutar;
                if(pOdenenTutar > mSepetler[pSepetIndex].toplamTutar){// ödenen tutar sepet toplamından büyükse
                    sorgu.bindValue(6, mSepetler[pSepetIndex].toplamTutar);// sepet toplam tutarı
                    mSepetler[pSepetIndex].kalanTutar = 0;
                }
                else if(pOdenenTutar <= mSepetler[pSepetIndex].toplamTutar){// ödenen tutar sepet toplam tutarından küçükse
                    sorgu.bindValue(6, pOdenenTutar);// ödenen tutar
                    mSepetler[pSepetIndex].kalanTutar += mSepetler[pSepetIndex].toplamTutar - pOdenenTutar; // kalan tutarı hesaplama
                }
                sorgu.bindValue(7, mSepetler[pSepetIndex].kalanTutar);// kalan tutar
                sorgu.bindValue(8, 1);//nakit ödeme tipinde satış
                sorgu.exec();
                if(sorgu.lastError().isValid()){
                    qDebug() << qPrintable(sorgu.lastError().text());
                }
            
                //kasa hareketi girme ve kasaya ödenen para kadar giriş
                if(pOdenenTutar > 0){// kasanın tutması için. cariye veresiye kaydedecekse odenen tutar 0 dan büyükse
                    // odenen para büyük veya eşitse sepettoplamtutarina sepetin tamamı ödendi demek.
                    if(pOdenenTutar >= mSepetler[pSepetIndex].toplamTutar){
                        kasaHareketiEkle(pKullaniciID,
                                         KasaHareketi::Giris,
                                         mSepetler[pSepetIndex].toplamTutar,
                                         "SATIŞ FAT.NO:" + FaturaNo,
                                         mSepetler[pSepetIndex].kazanc);
            
            //            if(satilacakSepet.getFazlaTutarAlacaklandir()){
            //                //yeni alış fatura bilgisi girme başlangıcı cariYonetimi classını bu sayfaya ekleyemediğim için böyle geçici çözdüm.
            
            //                double fazlaTutar = satilacakSepet.getOdenenTutar() - satilacakSepet.sepetToplamTutari();
            //                sorgu.prepare("INSERT INTO faturalar(id, fatura_no, cari, tipi, tarih, kullanici, toplamtutar, odenentutar, kalantutar, evrakno, aciklama, odemetipi) "
            //                                "VALUES (nextval('faturalar_sequence'), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
            //                sorgu.bindValue(0, yeniFaturaNo());
            //                sorgu.bindValue(1, satisYapilanCariID);
            //                sorgu.bindValue(2, 1);
            //                sorgu.bindValue(3, QDateTime::currentDateTime());
            //                sorgu.bindValue(4, satisYapanKullanici.getUserID());
            //                sorgu.bindValue(5, fazlaTutar);
            //                sorgu.bindValue(6, 0);
            //                sorgu.bindValue(7, fazlaTutar);
            //                sorgu.bindValue(8, "");
            //                sorgu.bindValue(9, FaturaNo + "'lu işlemde fazla ödenen tutar alacaklandirildi");
            //                sorgu.bindValue(10, 1);
            //                sorgu.exec();
            //                if(sorgu.lastError().isValid()){
            //                    qDebug() << qPrintable(sorgu.lastError().text());
            //                }
            //            }
            
                        //********************************************************
                    }
                    // odenen para küçükse sepettoplamtutarindan sepet eksik veya veresiye ödendi.
                    if(pOdenenTutar < mSepetler[pSepetIndex].toplamTutar){
                        kasaHareketiEkle(pKullaniciID,
                                         KasaHareketi::Giris,
                                         pOdenenTutar,
                                         "SATIŞ FAT.NO:" + FaturaNo,
                                         mSepetler[pSepetIndex].kazanc);// veresiye veya eksik ödediği için kar olarak eklemiyorum.
                    }
                }
            

            Ekran görüntüsü_2023-02-15_17-28-13.png

            jsulmJ 1 Reply Last reply
            0
            • M mamoo

              @jsulm I translate from google translate because my english is almost non-existent. I am sorry. it doesn't give any error message. it just reads my array variable 'mSepetler' as empty. However, I can read/write in 3 methods that I marked in the first picture I took.

              void SepetYonetimi::sepetiSat(const int pSepetIndex, const int pKullaniciID, const int pSatilanCariID, const double pOdenenTutar)
              {
                  QString FaturaNo = yeniFaturaNo();
                  //yeni fatura bilgisi girme başlangıcı
                  sorgu.prepare("INSERT INTO faturalar (id, fatura_no, cari, tipi, tarih, kullanici, toplamtutar, odenentutar, kalantutar, odemetipi) "
                                  "VALUES (nextval('faturalar_sequence'), ?, ?, ?, ?, ?, ?, ?, ?, ?)");
                  sorgu.bindValue(0, FaturaNo);
                  sorgu.bindValue(1, pSatilanCariID);
                  sorgu.bindValue(2, 2);// 2 = satış faturası (veritabanında faturatipleri.tip)
                  sorgu.bindValue(3, QDateTime::currentDateTime());
                  sorgu.bindValue(4, pKullaniciID);
                  sorgu.bindValue(5, mSepetler[pSepetIndex].toplamTutar); // sepet toplam tutarı
              
                  qDebug() << mSepetler[pSepetIndex].toplamTutar;
                  if(pOdenenTutar > mSepetler[pSepetIndex].toplamTutar){// ödenen tutar sepet toplamından büyükse
                      sorgu.bindValue(6, mSepetler[pSepetIndex].toplamTutar);// sepet toplam tutarı
                      mSepetler[pSepetIndex].kalanTutar = 0;
                  }
                  else if(pOdenenTutar <= mSepetler[pSepetIndex].toplamTutar){// ödenen tutar sepet toplam tutarından küçükse
                      sorgu.bindValue(6, pOdenenTutar);// ödenen tutar
                      mSepetler[pSepetIndex].kalanTutar += mSepetler[pSepetIndex].toplamTutar - pOdenenTutar; // kalan tutarı hesaplama
                  }
                  sorgu.bindValue(7, mSepetler[pSepetIndex].kalanTutar);// kalan tutar
                  sorgu.bindValue(8, 1);//nakit ödeme tipinde satış
                  sorgu.exec();
                  if(sorgu.lastError().isValid()){
                      qDebug() << qPrintable(sorgu.lastError().text());
                  }
              
                  //kasa hareketi girme ve kasaya ödenen para kadar giriş
                  if(pOdenenTutar > 0){// kasanın tutması için. cariye veresiye kaydedecekse odenen tutar 0 dan büyükse
                      // odenen para büyük veya eşitse sepettoplamtutarina sepetin tamamı ödendi demek.
                      if(pOdenenTutar >= mSepetler[pSepetIndex].toplamTutar){
                          kasaHareketiEkle(pKullaniciID,
                                           KasaHareketi::Giris,
                                           mSepetler[pSepetIndex].toplamTutar,
                                           "SATIŞ FAT.NO:" + FaturaNo,
                                           mSepetler[pSepetIndex].kazanc);
              
              //            if(satilacakSepet.getFazlaTutarAlacaklandir()){
              //                //yeni alış fatura bilgisi girme başlangıcı cariYonetimi classını bu sayfaya ekleyemediğim için böyle geçici çözdüm.
              
              //                double fazlaTutar = satilacakSepet.getOdenenTutar() - satilacakSepet.sepetToplamTutari();
              //                sorgu.prepare("INSERT INTO faturalar(id, fatura_no, cari, tipi, tarih, kullanici, toplamtutar, odenentutar, kalantutar, evrakno, aciklama, odemetipi) "
              //                                "VALUES (nextval('faturalar_sequence'), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
              //                sorgu.bindValue(0, yeniFaturaNo());
              //                sorgu.bindValue(1, satisYapilanCariID);
              //                sorgu.bindValue(2, 1);
              //                sorgu.bindValue(3, QDateTime::currentDateTime());
              //                sorgu.bindValue(4, satisYapanKullanici.getUserID());
              //                sorgu.bindValue(5, fazlaTutar);
              //                sorgu.bindValue(6, 0);
              //                sorgu.bindValue(7, fazlaTutar);
              //                sorgu.bindValue(8, "");
              //                sorgu.bindValue(9, FaturaNo + "'lu işlemde fazla ödenen tutar alacaklandirildi");
              //                sorgu.bindValue(10, 1);
              //                sorgu.exec();
              //                if(sorgu.lastError().isValid()){
              //                    qDebug() << qPrintable(sorgu.lastError().text());
              //                }
              //            }
              
                          //********************************************************
                      }
                      // odenen para küçükse sepettoplamtutarindan sepet eksik veya veresiye ödendi.
                      if(pOdenenTutar < mSepetler[pSepetIndex].toplamTutar){
                          kasaHareketiEkle(pKullaniciID,
                                           KasaHareketi::Giris,
                                           pOdenenTutar,
                                           "SATIŞ FAT.NO:" + FaturaNo,
                                           mSepetler[pSepetIndex].kazanc);// veresiye veya eksik ödediği için kar olarak eklemiyorum.
                      }
                  }
              

              Ekran görüntüsü_2023-02-15_17-28-13.png

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

              @mamoo said in I can't access the variable in the structure from within the class:

              it just reads my array variable 'mSepetler' as empty

              What exactly is "empty"?
              The array itself is for sure not empty as it has fixed size of 4 elements.
              You should really provide more details.

              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