c++

Qt get children from layout

Hi, I try to hide all widgets in layout. But looks like findChildren doesn't work for layout. Here's my sample code: QLayout * layout = widget -> findChild<QLayout *> (layoutName); QList<QWidget *> list = layout -> findChildren<QWidget *> (); cout << list.size() << endl; size is 0, but inside this layout I have a fe...

C++ -- Question about typedef

Given the following code: typedef struct IntElement { struct IntElement *next; // use struct IntElement int data; } IntElement; typedef struct IntElement { IntElement *next; // Use IntElement int data; } IntElement; // why I can re-use IntElement here? I use above data structure to define a linked-list...

Find and eject a USB device based on its VID/PID

I want to send an eject command to a specific USB device identified by it's VID and PID. I can find the device by using SetupDiEnumDeviceInfo() and SetupDiGetDeviceRegistryProperty() and matching the VID/PID numbers in the HARDWAREID string but that's as far as I've got. I have a SP_DEVINFO_DATA struct and a HDEVINFO handle. How would I...

C++: "Class namespaces"?

If in C++ I have a class longUnderstandableName. For that class I have a header file containing its method declaration. In the source file for the class, I have to write longUnderstandableName::MethodA, longUnderstandableName::MethodB and so on, everywhere. Can I somehow make use of namespaces or something else so I can just write Metho...

C++ - Stack Pop() Function with Singly Linked list

For starters this is apart of my current homework assignment for my Data Structures class. I am not asking for answers, I am asking for help. I have a stack class that is implementing a Linked List instead of an array. I am currently trying to write my pop() function. I have a node for my theBack part of the stack. I am just confused a...

What type of class do I need for this?

I want to create a class that is usable without being instanced, but that can also be instanced. Similar to a math class I suppose. Thanks ...

Basic C++: How do I initialize a struct member of a class?

Hi all. I've looked all over the place, but haven't found an answer to this. I have a C++ class with these protected members: struct tm _creationDate; struct tm _expirationDate; struct tm _lockDate; I want to initialize them at instantiation time. If I put this in the constructor: _creationDate = {0}; _expirationDate = {0}...

Lightweight boost::optional

I currently can't use boost in a project and I've found myself missing boost::optional. I've found this blog post which shows the idea behind boosts implementation. However, it doesn't take into account memory alignment issues and I'm not well versed enough in C++ to make the necessary changes. Does anyone know of an simple implement...

How do I insert queue elements into a vector?

I have typedef std::queue<MyObject*> InputQueue; std::vector<InputQueue> inp_queue; Now what I want to do is define at runtime say 5 queues and place data on those queues like inp_queue[1].push(new MyObject()); etc. I got it to compile, but it core dumps right away. I guess I need to actually add the queues to the vector first (...