Skip to content

C++ Gurus

The forum for all discussions in C++ land.
1.3k Topics 8.5k Posts
  • please clarify std::ratio using

    Unsolved
    1
    0 Votes
    1 Posts
    145 Views
    No one has replied
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    10 Views
    No one has replied
  • Weird array properties

    Unsolved
    3
    0 Votes
    3 Posts
    270 Views
    JonBJ

    @ItsRhysNotRhys
    In order to get from

    Printing Queue: 4 5 0

    to

    2 left in queue inside moveElevator1 Printing Queue: 3 5 0

    something outside the code you are showing us (maybe in whatever issues two of those message lines) is writing 3 to queue[0]. Either directly, or just possibly through buffer over/underflow writing to another member variable adjacent to int queue[20] .

  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    1 Views
    No one has replied
  • 0 Votes
    7 Posts
    566 Views
    aha_1980A

    And to add to @Chris-Kawa:

    If you use C++11 or higher, you should init the members directly at their declaration: bool m_foo = false;. At least that's what I do.

    Regards

  • Forward references in class definition

    Solved
    9
    0 Votes
    9 Posts
    535 Views
    JonBJ

    @SimonSchroeder
    Details! And as far as I know Denmark & Sweden are more or less the same country anyway ;-)

  • To static or not to static?

    Solved
    19
    0 Votes
    19 Posts
    1k Views
    JoeCFDJ

    @JonB I guess both ways work. I do not have preference.

  • 0 Votes
    13 Posts
    2k Views
    JoeCFDJ

    @Qt-embedded-developer app looks like using stack(not heap) memory. when classNamePtr is cleared, it will try to destroy &app and your app will crash likely.

  • when to use static class object pointer ?

    Solved
    7
    0 Votes
    7 Posts
    909 Views
    Christian EhrlicherC

    @Qt-embedded-developer lmgtfy: https://doc.qt.io/qt-6/model-view-programming.html

  • How to make QProcess "interactive" ?

    Unsolved
    15
    0 Votes
    15 Posts
    2k Views
    JonBJ

    @AnneRanch
    Anne, I explained both of these above. You ask for clarification but what can I say further to what In have written? Summary:

    The command you are issuing, gnome-terminal lsusb, is not and never has been the correct syntax to ask gnome-terminal to run a command. It ignores the lsusb completely and simply runs gnome-terminal. So you see an interactive terminal window sitting there instead. For Ubuntu the command should be gnome-terminal -- lsusb. That will open the window, run lsusb and close the window when that finishes. Which happens so quickly in milliseconds that you simply won't see anything, the window will open and close faster than you can see. Which is why I said if you were to run gnome-terminal -- find / -print you will get to see what actually is happening. You can try these outside of your Qt program from a terminal.

    If you invoke gnome-terminal, or any other "terminal" such as xterm, to run a command (such as lsusb) the terminal will attach its stdout to the window it opens. That means no matter what your calling program --- a Linux shell or a Qt application --- it will not receive or be able to access any output the command (lsusb or whatever) produces e.g. on its stdout. That will go to the terminal window and cannot be seen by the calling application.

    As per when we discussed this a year or two ago and I said then, if you want to be able to read back the output from, say, lsusb you must run it directly (as the command you tell QProcess to start) and not invoke any gnome-terminal or xterm or other terminal to run it.

  • How qt 5.15.11 for mac os is built?

    Unsolved
    1
    0 Votes
    1 Posts
    144 Views
    No one has replied
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    9 Views
    No one has replied
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    40 Views
    No one has replied
  • help to find "connect" error

    Unsolved
    11
    0 Votes
    11 Posts
    609 Views
    JonBJ

    @J-Hilk said in help to find "connect" error:

    And like I quoted, her 2nd comment clearly states static member variables of index and index_sub

    Evidently easier to spot that by some (you) than by others (me)! There is a lot to wade through (unformatted), and it always helps to show the relevant code...! :)

    Anyway, hopefully the OP has a couple of alternative ways to modify the code now to get the behaviour desired.

  • Adapting QStringList to "two level" array

    Unsolved
    10
    0 Votes
    10 Posts
    1k Views
    A

    @mpergand Thanks for the reply. I have taken the liberty to modify your code as far as using "connect" and lambda. It is doing a good job for my purpose.
    There is an issue with using correct "connect" sender and trigger... and I am working on that.
    ( I did post a request for C++ code help here ... sorry OF does not member the post title....)

    Anyway - you deserve credit for your code
    appreciate it very much
    ,

  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    12 Views
    No one has replied
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    21 Views
    No one has replied
  • need help understanding "connect"

    Unsolved
    3
    0 Votes
    3 Posts
    376 Views
    Axel SpoerlA

    @AnneRanch
    To make your code work, you need to do the right things right. I don’t know exactly what you want to achieve. How your menus should look like. Draw them on a sheet of paper and post a photo.
    Your issues are not related to understanding “connect”. Your connect statements are syntactically correct, meaning you are doing it right. But you want to connect signals from objects in a nested container all to the same slot. So the slot has to know, who fired the signal. That’s where the drama starts. Why hide information at one place by architecture, so you have to dig it out on the other end, in the slot. Why not write a slot or a lambda for each action you want to connect to? Your issue is in the loops around nested containers, not in “connect”. I haven’t seen a use case that requires such a complicated structure. Maybe it’s necessary in your case. Let us know. Tell us why. You are not handling the structure well, otherwise you wouldn’t connect to a nullptr. If you want to fix your code, this is where to look.

  • code analysis - please

    Unsolved
    2
    0 Votes
    2 Posts
    219 Views
    Christian EhrlicherC

    Already asked and answered here: https://forum.qt.io/topic/154053/connect-won-t

  • Strange behaviour with QString class members

    Unsolved
    12
    0 Votes
    12 Posts
    771 Views
    MesrineM

    @Axel-Spoerl

    Yeah, but if I move it back it gives the runtime error :) .
    I will try some stack trace and posted here.
    Also, I will try changing the name of the function as suggested by the remaining binary artifacts idea.