There are a couple of errors here and some weird unused code. Lets go over it:

setGeometry: Unable to set geometry (...) - this is just a warning. A widget has a 0 minimum size and minimum size hint by default. You used a layout on it so it has some margins (11 px in this case) Because of the frame of the window a window manager can't create a window that small so it resizes it to a smallest possible size and lets you know with a warning. To fix it either use setMinimumSize() or override minimumSizeHintfor your widget.

QPainter related messages - you're creating a painter as a class member variable. Don't do that. Create the painter locally in the paint event with a proper surface to use it on:

What's the layout for? Are you gonna put something in it? If yes then remember that it will obscure whatever you paint in your paint event.

You're not deleting the dLine variable in main(). It's leaking. Either create it on the stack (which is the easiest and recommended), set a Qt::WA_DeleteOnClose attribute on it or delete it manually after the a.exec() call returns (pointless manual work).

just a hint - when overriding virtual methods use override specifier. It will save you a lot of typo related bugs: