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. Function running before it is expected
Forum Updated to NodeBB v4.3 + New Features

Function running before it is expected

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 279 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.
  • J Offline
    J Offline
    john_hobbyist
    wrote on last edited by john_hobbyist
    #1

    Hello, I use this code here: https://github.com/Axel-Erfurt/OrthoViewLite/blob/main/OrthoViewLite.py
    I have written a function in order to do some processing. Where should I call it in order to do the processing, after the 3 files ( I changed the code to include total 3 file buttons, everything runs ok to this point) are inserted? Because as I call it now it runs before the 3 files are inserted, although I call it at the end of init(self, parent=None) function. I defined it between the positions:

    def openFile()
    

    and

    def getFrame()
    

    I see different behaviour (if I am not wrong) of the python functions comparing to C/C++ (where they execute only where you call them). Thanks...

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

      Hi,

      Don't call your function in __init__. This will just make it run every time you create an object of that class. What you want is to check if all the files have been selected each time one of the buttons are clicked and only then call it.

      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
      1
      • J Offline
        J Offline
        john_hobbyist
        wrote on last edited by john_hobbyist
        #3

        Ok I found the error...

        I want to compare two strings and check if they are the same. For example, this string:

        "This is a sentence"

        with this:

        " This is a sentence "

        As can be seen they are not to the same since the last sentence has before and after the sentence spaces. How do I do this kind of comparisons?

        JonBJ 1 Reply Last reply
        0
        • J john_hobbyist

          Ok I found the error...

          I want to compare two strings and check if they are the same. For example, this string:

          "This is a sentence"

          with this:

          " This is a sentence "

          As can be seen they are not to the same since the last sentence has before and after the sentence spaces. How do I do this kind of comparisons?

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @john_hobbyist
          Do what kind of comparisons? Are you really asking someone to tell you to/how to strip spaces?

          1 Reply Last reply
          1

          • Login

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