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. QStack<QJsonValue>, peek not found...
Forum Updated to NodeBB v4.3 + New Features

QStack<QJsonValue>, peek not found...

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 456 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.
  • SPlattenS Offline
    SPlattenS Offline
    SPlatten
    wrote on last edited by
    #1

    I am using a QStack<QJsonValue>, in my push function I want to check if the last value push is the same and if yes, do nothing, my pseudo logic:

    1. Does stack contain at least 1 item?  
    2. If No goto 5
    3. If Yes, is the last entry pushed the same as the new value waiting to be pushed?
    4. Yes, its the same, do nothing and return
    5. Push new value to stack.
    

    From searching google it seems that a peek use to be available, I'm using Qt 5.15.2

    Kind Regards,
    Sy

    Christian EhrlicherC 1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #4

      @SPlatten said in QStack<QJsonValue>, peek not found...:

      const QJsonValue& crobjLast(last());

      You should use QStack::top()

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      SPlattenS 1 Reply Last reply
      3
      • SPlattenS SPlatten

        I am using a QStack<QJsonValue>, in my push function I want to check if the last value push is the same and if yes, do nothing, my pseudo logic:

        1. Does stack contain at least 1 item?  
        2. If No goto 5
        3. If Yes, is the last entry pushed the same as the new value waiting to be pushed?
        4. Yes, its the same, do nothing and return
        5. Push new value to stack.
        

        From searching google it seems that a peek use to be available, I'm using Qt 5.15.2

        Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #2

        @SPlatten said in QStack<QJsonValue>, peek not found...:

        From searching google it seems that a peek use to be available, I'm using Qt 5.15.2

        Why not simply looking in the documentation?

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        SPlattenS 1 Reply Last reply
        2
        • Christian EhrlicherC Christian Ehrlicher

          @SPlatten said in QStack<QJsonValue>, peek not found...:

          From searching google it seems that a peek use to be available, I'm using Qt 5.15.2

          Why not simply looking in the documentation?

          SPlattenS Offline
          SPlattenS Offline
          SPlatten
          wrote on last edited by SPlatten
          #3

          @Christian-Ehrlicher , just implemented:

          void clsQtJsonStack::push(const QJsonValue& crobjValue) {
              if ( isEmpty() != true ) {
              //Get last value pushed to stack
                  const QJsonValue& crobjLast(last());
                  if ( crobjLast == crobjValue ) {
              //Last is same as new value, do nothing
                      return;
                  }
              }
              QStack::push(crobjValue);
          }
          

          Kind Regards,
          Sy

          1 Reply Last reply
          0
          • Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #4

            @SPlatten said in QStack<QJsonValue>, peek not found...:

            const QJsonValue& crobjLast(last());

            You should use QStack::top()

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            SPlattenS 1 Reply Last reply
            3
            • Christian EhrlicherC Christian Ehrlicher

              @SPlatten said in QStack<QJsonValue>, peek not found...:

              const QJsonValue& crobjLast(last());

              You should use QStack::top()

              SPlattenS Offline
              SPlattenS Offline
              SPlatten
              wrote on last edited by
              #5

              @Christian-Ehrlicher, thank you, just realised the same during debugging.

              Kind Regards,
              Sy

              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