Designer produces invalid code?
I use Designer, that is integrated inside Visual Studio. If I make a GUI class that inherits QPixmap, I get some errors regarding objectName and setObjectName. It seems that QPixmap does not inherit QObject?? And how it is that Designer does not know that?
Re: Designer produces invalid code?
What do you mean a GUI class that inherits QPixmap? In Designer? Could you explain?
Re: Designer produces invalid code?
OK, I will try to explain better. In Visual Studio I select Project -> Add Qt GUI Class. There is line edit field named "Base Class". If I type in QPixmap as base class, then code that is produced by Designer is invalid. I gett errors such as objectName is not a member of QPixmap and similar. If base class is QDialog or QWidget, there are obviously no errors because these two classes inherit QObject. Am I missing something here?
Re: Designer produces invalid code?
Quote:
Originally Posted by
Tiansen
Am I missing something here?
Yes, you are responsible for writing a sensible class name there. Basically it could be a custom base class so no checks are made. Writing QPixmap there makes no sense because QPixmap is not a QWidget.
Re: Designer produces invalid code?
If I select Project -> Add Qt Class instead of Project -> Add GUI Qt Class, then constructor is invalid. I get this error:
Quote:
error C2664: 'QPixmap::QPixmap(const QSize &)' : cannot convert parameter 1 from 'QObject*' to 'const QSize &'
1> Reason: cannot convert from 'QObject *' to 'const QSize'
1> No constructor could take the source type, or constructor overload resolution was ambiguous
It seems to me that Designer doesn't support adding QPixmap widget. If I am missing something please help me see how dumb I am ;)
Re: Designer produces invalid code?
jpn, so this means QPixmap does not originate from QObject either? I am just trying to display some image in my application. So it seems QPixmap is not the right class to use. Can you recommend me which class that IS widget should I use? Hmm, maybe QLabel would be better option?
Re: Designer produces invalid code?
Quote:
Originally Posted by
Tiansen
jpn, so this means QPixmap does not originate from QObject either?
QPixmap is not GUI component. QPixmap only represents image data.
Quote:
I am just trying to display some image in my application. So it seems QPixmap is not the right class to use. Can you recommend me which class that IS widget should I use? Hmm, maybe QLabel would be better option?
You should use one of the readily available options; QWidget, QDialog or QMainWindow. Then you will just add a QLabel widget on the form and set a pixmap on the label.
Re: Designer produces invalid code?
Yes, you are right. I did not know that I must use QLabel to display image. Now it works. Thank you very much!