Skip to content

C++ Gurus

The forum for all discussions in C++ land.
1.3k Topics 8.5k Posts
QtWS25 Last Chance
  • help to find "connect" error

    Unsolved
    11
    0 Votes
    11 Posts
    778 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
    2k 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
    448 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
    289 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
    1k 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.
  • connect won't...

    Unsolved
    5
    0 Votes
    5 Posts
    544 Views
    Axel SpoerlA
    @AnneRanch said in connect won't...: Here's your problem: QObject::connect(QAction, MainWindow_Bluetooth): invalid nullptr parameter The array you use for the connect statement isn't populated properly. At this location: connect(subAction[index_sub] , &QAction::triggered, this , [=]() { this->process_TEST() ;}); ...you have a nullptr in subAction[index_sub]. That's probably a result of the somewhat unusual approach to store actions in an array.
  • Synthesis of == from operator<=>

    Solved
    4
    0 Votes
    4 Posts
    552 Views
    A
    @SGaist Many thanks, I must have missed that one!
  • Please help with actual C++ code

    Unsolved
    25
    0 Votes
    25 Posts
    3k Views
    JonBJ
    @AnneRanch but I am unable to add "check box" to any of them QAction *action = submenu[index]->addAction("Some text"); action->setCheckable(true); adds an action with text Some text and sets it to have a checkbox.
  • Main menu set with submenu - triggering issue

    Unsolved
    5
    0 Votes
    5 Posts
    600 Views
    JonBJ
    @AnneRanch You may have been trying to do what I did some time ago, but discovered it does not work so is not allowed in Qt. If you have a sub-menu on a menu --- i.e. the menu has that > you click on to "slide out" the sub-menu --- then although Qt allows you also put a checkbox on the parent menu item which has the > slide-out it actually does not work correctly for checking the box, and cannot be made to do so. Do not try to put a checkbox on a menu item which has a child menu slide-out.
  • Passing a value to slot...

    Unsolved
    18
    0 Votes
    18 Posts
    2k Views
    JonBJ
    @AnneRanch said in Passing a value to slot...: Minor detail; you example is missing the closing "}" - but the compiler catches that, no big deal. You are correct, my bad. I just type these examples in, my eyesight is not what it used to be! (I believe) I have corrected both my previous posts to have that missing }.
  • Whar is this error saying?

    Unsolved
    6
    0 Votes
    6 Posts
    595 Views
    J.HilkJ
    @AnneRanch said in Whar is this error saying?: Thanks , I wad actually triggering on wrong action before. I guess I will never know why I how to read the "() " error to correct my code. The compiler is actually exactly telling you why it has a problem with the (missing) brackets, I'll quote the part: cpp-compiler said in mainwindow_Bluetooth.cpp error: expected '(' for function-style cast or type construction it thinks your bool is an attempt of you to cast something to an boolean and it thinks the silly programmer forgot to add the bracket and the actual variable that is supposed to be cast. something like this: int a = 0; auto b = bool(a); or in your particular case: void triggered(bool variable) { qDebug() << variable } .... int a = 0; triggered(bool(a)); The compiler doesn't know that function style cast do only the other people, true c++ programers don't use it at all.
  • QMenu . QAction how can I add "checked "?

    Unsolved
    7
    0 Votes
    7 Posts
    712 Views
    A
    FINALLY... here a current WORKING as expected - both menu and submenu have check boxes and only main menu has "arrows".... Unless there are objections I am going to clean up the worthless code... Thanks foe sticking with the problem... mainAction[index_main] = m_ui->menuWindow_cpntrol->addAction(list[ index_main] + " #" + QString::number( index_main)); mainAction[index_main]->setCheckable(true); //adds arrows mainAction[index_main]->setMenu(tempmenu); subAction[index_main] = tempmenu->addAction(list_hcitool[ index_main] + " #" + QString::number( index_main)); subAction[index_main]->setCheckable(true);
  • QMenu C++ code help

    Unsolved
    6
    0 Votes
    6 Posts
    606 Views
    JonBJ
    @AnneRanch said in QMenu C++ code help: That is the issue - how to change "checkable" property when there is access only to QMenu. That is what you wrote. So I took the time to answer it exactly. You cannot get directly from a QAction * to the QMenu you put it on, unlike the other way round which you asked and is answered. However, you can use QList<QObject *> QAction::associatedObjects() const from a QAction and you should find the QMenu it has been added to among them. And you add submenus to a menu. Which answers the new question.
  • QMenu - submenu arrow removal

    Solved
    6
    0 Votes
    6 Posts
    666 Views
    Axel SpoerlA
    @AnneRanch said in QMenu - submenu arrow removal: my OS is Linux Same here. Start spectacle, define a delay of e.g. 10s, choose a rectangle or select "Active Window". Then you have 10s to bring the menu up and keep it. But I assume you won't do it anyway, as usual.
  • What "Parentheses" am I missing ?

    Unsolved
    4
    0 Votes
    4 Posts
    437 Views
    Axel SpoerlA
    @AnneRanch The recommended way is: connect(subAction[index], &yourClass::triggered, this, &thisClass::testSlot);
  • This topic is deleted!

    Unsolved
    2
    0 Votes
    2 Posts
    17 Views
  • Add to mdiArea using C++ code and QTDesigner

    Solved
    1
    0 Votes
    1 Posts
    189 Views
    No one has replied
  • Process Protection

    Unsolved
    12
    0 Votes
    12 Posts
    2k Views
    TomZT
    @Chris-Kawa said in Process Protection: If what you're saying was universal the entire gaming industry wouldn't exist and wouldn't be the biggest entertainment medium in the world as it is. I'd like to point out that there is no conflict in that world and what I wrote. See this description; https://www.theverge.com/2021/9/23/22690670/epic-eac-anti-cheat-linux-valve-steam-deck-support-games EasyAntiCheat is a company that doesn't focus on process protection in the way that OP asked. For starters it requires kernel support.