Skip to content

C++ Gurus

The forum for all discussions in C++ land.
1.3k Topics 8.6k Posts
  • QT connect versus socket connect...

    Unsolved
    3
    0 Votes
    3 Posts
    557 Views
    Christian EhrlicherC
    ... and the groundhog says hello every day year: https://forum.qt.io/topic/121943/whoops-complier-see-qt-connect-is-a-dupe
  • Help me code and understand "foreach"

    Unsolved
    9
    0 Votes
    9 Posts
    1k Views
    JonBJ
    auto existed in C from the start too! It just didn't mean the same as now in C++, and was pointless :) void func() { auto int i; }
  • What is benefits of assigning shared pointer to weak pointer ?

    Solved
    2
    0 Votes
    2 Posts
    501 Views
    TomZT
    shared pointer and weak pointer are there for memory management or lifetime management. It has nothing to do with MVC. The point of shared pointers is that they make sure your object is deleted only when the last one stops using that. The point of a weak pointer is that they allow the object to be deleted which a shared pointer doesn't allow.
  • Help OF with (adding ) "include" path ....

    Unsolved when
    4
    0 Votes
    4 Posts
    650 Views
    Chris KawaC
    .. is just a part of a path meaning "one folder up". So you build your path just as you would "click it" in file explorer. Lets say you have a file structure like this: top project1 something header.h project2 something file.cpp and you want to include header1 in file.cpp. When starting from file.cpp location in a file explorer you would go two directories up and then two directories down to header.h. It's the same when constructing an include path. You start where the file you are in is. You go up twice and then down twice to the header, so: #include "../../project1/something/header.h" start in top/project2/something/ because that's where file.cpp is first .. takes you one up to top/project2/ second .. takes you up to top/ and then project1/something/ takes you to the header. But as @fcarney said that's not a good idea because you're hardcoding in your source a path to another project. That's not something you should do. What you should do is add a base path to the other project to your INCLUDEPATH variable and then you can make includes relative to that. So in the above example you would add path to project1 in project2 like this: INCLUDEPATH += ../project1 and then you could make a clean include like this in your file.cpp: #include "something/header.h".
  • This topic is deleted!

    Locked Unsolved
    2
    0 Votes
    2 Posts
    36 Views
  • How to add another constructor ?

    Unsolved
    2
    0 Votes
    2 Posts
    440 Views
    Christian EhrlicherC
    @AnneRanch said in How to add another constructor ?: How do I pass a option to run SPECIFIC constructor ? Simply change your ctor to get a- QWidget pointer as first parameter - it's nothing more than a normal function.
  • How to add preprocessor directive into .pro ?

    Solved
    7
    0 Votes
    7 Posts
    2k Views
    A
    SOLVED putting DEFINES += define DEBUG in main .pro file has same effect as putting in #define DEBUG here is a snippet of compiler output? clang++ -c -pipe -g -std=gnu++1z -Wall -Wextra -fPIC -D_REENTRANT **-Ddefine -DDEBUG** -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_BLUETOOTH_LIB -DQT_NETWORK_LIB -DQT_DBUS_LIB -DQT_CORE_LIB -I. -I/home/nov25-1/Qt/Nov26/6.5.0/gcc_64/include -I/home/nov25-1/Qt/Nov26/6.5.0/gcc_64/include/QtWidgets -I/home/nov25-1/Qt/Nov26/6.5.0/gcc_64/include/QtGui -I/home/nov25-1/Qt/Nov26/6.5.0/gcc_64/include/QtBluetooth -I/home/nov25-1/Qt/Nov26/6.5.0/gcc_64/include/QtNetwork -I/home/nov25-1/Qt/Nov26/6.5.0/gcc_64/include/QtDBus
  • how to implement for / foreach iteration ?

    Unsolved
    2
    0 Votes
    2 Posts
    503 Views
    Christian EhrlicherC
    The old-style Qt-way (pre c++11) - see https://www.kdab.com/goodbye-q_foreach/ - don't use it. For c++11 and later: https://en.cppreference.com/w/cpp/language/range-for (see examples)
  • Need help with C++ syntax - repost

    Unsolved
    19
    0 Votes
    19 Posts
    2k Views
    A
    SUCCESS SOLVED CASE CLOSED (?) [image: 8d0fc410-826a-4d52-92ff-ffe3cc15849f.png] The moral of the story changing the name of the header file has no effect in changing the object name in the "form" [image: 2706ade4-c78c-485b-a8e6-b20434e85fa9.png] Thanks to all for much needed assistance , especially Chis.
  • why qt6 add more compiled-time check and caused some unexpected errors

    Solved moc qt6.2 template
    12
    0 Votes
    12 Posts
    2k Views
    Chris KawaC
    @ComixHe No problem. Oh, you also said that you now need C++17. Yes, the minimum language version requirement in Qt6 was bumped from C++11 to C++17. It makes a lot stuff easier, the implementation can be cleaner and it is supported by all major compilers anyway.
  • how to use regex to verify a certain string pattern?

    Moved Solved
    4
    0 Votes
    4 Posts
    1k Views
    Kent-DorfmanK
    mathematically speaking both expressions are valid. -5x^0 evalutates to -5 so the term is the same even if it is expressed differently.
  • displays differently with 5.15.7 build than 5.0.1 build

    Unsolved
    6
    0 Votes
    6 Posts
    825 Views
    W
    added -platform windows:dpiawareness=0 and back to where I was before. Many thanks!
  • This topic is deleted!

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

    Unsolved
    1
    0 Votes
    1 Posts
    1 Views
    No one has replied
  • error-[-Werror=unused-but-set-variable]

    Unsolved
    4
    0 Votes
    4 Posts
    2k Views
    A
    Thanks @JonB and @SGaist. You are right, I have removed that variable and now its working fine. Thanks again for your help.
  • Help me understand C++ constructor syntax

    Solved
    6
    0 Votes
    6 Posts
    1k Views
    Chris KawaC
    @AnneRanch said: would "allocate an instance of class" be same as " build an object of class " Yes
  • Deep Python Encapsulation

    Solved
    11
    0 Votes
    11 Posts
    1k Views
    TomZT
    In QtCreator I have warnings from my linter (cppcheck) when I create local variables that shadow class-things (including method-names).
  • semantic error

    Unsolved
    7
    0 Votes
    7 Posts
    1k Views
    A
    @JonB Yes I have debug.h file in my project. I have renamed that and checked. Now it is not showing that error. Thank you so much.
  • Error ....undefined reference to `operator delete...QT 5.15.2

    Unsolved
    4
    0 Votes
    4 Posts
    2k Views
    A
    @AnneRanch ABANDONED I have found another full copy of my project. Without any modification - using same kit and same version of Ubuntu - it compiles and run . I am loosing patience to troubleshoot tools looking for weird failures like this one, I like to spent my time doing constructive work and I need to continue building my project. However, I do appreciate the forum replies... Cheers
  • 0 Votes
    5 Posts
    1k Views
    S
    @SalemSabrehagen said in How to make use of latest QProcess::startDetached function with argument when starting external apps?: but there must be a reason for change. I can only guess. But, I would say the new way is much better. Having all arguments as separate entries in a list does away with having to quote some arguments and escaping quotes where necessary. Sure, this only applies to arguments which have spaces inside them (which is rarely the case), but in general it is much better. In your case with calling bash with arguments it is certainly a much better way. There are countless posts on this forum (both Windows- and Linux-related) where people got this wrong (using the old way).