PierreA
6th August 2017, 07:04
I have a class DotCanvas: public QWidget that shows a pattern of dots. I also have some blank buttons which I'd like to label with dot patterns. So what I'm thinking of doing is making a class DotPixmap: public QPixmap with 256×256 pixel array, draw the patterns on them, load them into the icons, and load the icons into the buttons.
So I try to create a class DotPaintDevice which has the dot-painting code, and subclass DotCanvas from both QWidget and DotPaintDevice. I've done multiple inheritance before, so I figure I can do it, using "using" statements to tell the compiler from which superclass a subclass inherits an ambiguous function, if necessary. I compile it and get this:
/home/phma/src/mirasol/dotcanvas.h:38: Warning: Class DotCanvas inherits from two QObject subclasses QWidget and DotPaintDevice. This is not supported!
followed by lots of errors. I manage to fix some errors, but there are errors in compiling the moc output, which I haven't a clue what to do with.
So it looks like I have to duplicate the dot-painting code in two classes, one subclass of QWidget and one subclass of QPixmap. For this program the dot-painting code is simple, but how do you do it when you have some complicated stuff to display and you want to display and print the same stuff? Which I will, when I get around to adding the GUI to another program I'm working on.
So I try to create a class DotPaintDevice which has the dot-painting code, and subclass DotCanvas from both QWidget and DotPaintDevice. I've done multiple inheritance before, so I figure I can do it, using "using" statements to tell the compiler from which superclass a subclass inherits an ambiguous function, if necessary. I compile it and get this:
/home/phma/src/mirasol/dotcanvas.h:38: Warning: Class DotCanvas inherits from two QObject subclasses QWidget and DotPaintDevice. This is not supported!
followed by lots of errors. I manage to fix some errors, but there are errors in compiling the moc output, which I haven't a clue what to do with.
So it looks like I have to duplicate the dot-painting code in two classes, one subclass of QWidget and one subclass of QPixmap. For this program the dot-painting code is simple, but how do you do it when you have some complicated stuff to display and you want to display and print the same stuff? Which I will, when I get around to adding the GUI to another program I'm working on.