2023-08-29

Why isn't there a slider version of QInputDialog?

I need a quick-n-dirty UI element in my QT-based application for selecting a number. A number with a well defined lower limit (certainly not less than one, but honestly even 5 is kinda silly) and a fuzzier but still very finite upper limit (somewhere between 60 and 100, I'd say).

Now, there is QInputDialog::getInt which is what I'm going to end up using, but ... it's a natural use-case for a slider and there seems to be no similar convenience class supplying that particular functionality. Grrrrrrr!

2023-08-28

The invention of fanfic

I've been reading The Hobbit to the child for bedtime story recently. Bit of a slog at times because (a) she falls asleep in the most surprising places in the text, (b) frequent stops to discuss new vocabulary and previously unknown customs, and (c) lengthy interruptions to hear how she things the story should proceed. That latter bit came to a head tonight as we neared the end of Chapter 8. She believes that the story would be better if we dispensed with the spiders and added some unicorns and has decides to make up her own, improved version.

2023-08-05

What if it's untestable?

I've been working on evolving some code down in my project's foundation to enable to user visible improvements. My stategy involves the C++ standard library facility variant which allows the user to stores a single value at any given time but from multiple different types. For those of you with the proper background this is an improved union.1 It also provides some basic infrastructure for the situation when it does not hold a value at all, and I've been diligently covering my a all the bases as I go along.

Now I want to test so aspects of the work I've done so far.

Testing the "variant is in a bad, bad place" code means making a variant in a bad, bad place. Only it turns out that is not at all easy.2 There isn't a facility to make one. Not brand new to made-to-order, nor from an existing one by any usual means. cpp reference says

A variant may become valueless in the following situations:
  • (guaranteed) an exception is thrown during the initialization of the contained value during move assignment
  • (optionally) an exception is thrown during the initialization of the contained value during copy assignment
  • (optionally) an exception is thrown when initializing the contained value during a type-changing assignment
  • (optionally) an exception is thrown when initializing the contained value during a type-changing emplace
and it includs a sample of code to do the job, and a link to an online platform to compiler and run and see that it does the job. Now that code uses a custom type so I can't use it directly, but where I try to ape it using one of the types in my variant ... it doesn't work. I'm able write code that will hit all the last three conditions, but apparently my compiler is too smart for that.

Well, given how hard it is to access that state maybe testing the code that handles is houldn't be a high priority, but I"m annoyed.


1 Nor is it anything like a new idea, but it wasn't made part of the C++ standard library until the 2017 standard. Thankfully, by project has moved that far forward in time.

2 Of course this is a good thing. Except that it isn't quite impossible, so there is all that infrastructure there for handling the special case. Argh!