Skip to content

C++ Gurus

The forum for all discussions in C++ land.
1.3k Topics 8.5k Posts
  • How qt 5.15.11 for mac os is built?

    Unsolved 14 Feb 2024, 12:09
    0 Votes
    1 Posts
    204 Views
    No one has replied
  • This topic is deleted!

    Unsolved 6 Feb 2024, 17:51
    0 Votes
    1 Posts
    9 Views
    No one has replied
  • This topic is deleted!

    Unsolved 5 Feb 2024, 19:16
    0 Votes
    1 Posts
    40 Views
    No one has replied
  • help to find "connect" error

    Unsolved 4 Feb 2024, 02:09
    0 Votes
    11 Posts
    848 Views
    @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 23 Jan 2024, 16:41
    0 Votes
    10 Posts
    2k Views
    @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 4 Feb 2024, 02:53
    0 Votes
    1 Posts
    12 Views
    No one has replied
  • This topic is deleted!

    Unsolved 29 Jan 2024, 19:26
    0 Votes
    1 Posts
    21 Views
    No one has replied
  • need help understanding "connect"

    Unsolved 26 Jan 2024, 22:17
    0 Votes
    3 Posts
    472 Views
    @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 26 Jan 2024, 18:31
    0 Votes
    2 Posts
    308 Views
    Already asked and answered here: https://forum.qt.io/topic/154053/connect-won-t
  • Strange behaviour with QString class members

    Unsolved 24 Jan 2024, 09:50
    0 Votes
    12 Posts
    1k Views
    @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 24 Jan 2024, 02:34
    0 Votes
    5 Posts
    620 Views
    @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 22 Jan 2024, 09:53
    0 Votes
    4 Posts
    604 Views
    @SGaist Many thanks, I must have missed that one!
  • Please help with actual C++ code

    Unsolved 20 Jan 2024, 15:48
    0 Votes
    25 Posts
    3k Views
    @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 19 Jan 2024, 17:22
    0 Votes
    5 Posts
    639 Views
    @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 Jan 2024, 00:28
    0 Votes
    18 Posts
    2k Views
    @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 17 Jan 2024, 18:43
    0 Votes
    6 Posts
    666 Views
    @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 14 Jan 2024, 02:05
    0 Votes
    7 Posts
    757 Views
    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 13 Jan 2024, 20:23
    0 Votes
    6 Posts
    661 Views
    @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 11 Jan 2024, 17:31
    0 Votes
    6 Posts
    714 Views
    @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 11 Jan 2024, 20:03
    0 Votes
    4 Posts
    478 Views
    @AnneRanch The recommended way is: connect(subAction[index], &yourClass::triggered, this, &thisClass::testSlot);