Results 1 to 8 of 8

Thread: Designer produces invalid code?

  1. #1
    Join Date
    Feb 2008
    Posts
    79
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default 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?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Designer produces invalid code?

    What do you mean a GUI class that inherits QPixmap? In Designer? Could you explain?

  3. #3
    Join Date
    Feb 2008
    Posts
    79
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default 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?

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Designer produces invalid code?

    Quote Originally Posted by Tiansen View Post
    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.
    J-P Nurmi

  5. #5
    Join Date
    Feb 2008
    Posts
    79
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default 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:

    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
    Last edited by jpn; 4th March 2008 at 12:34. Reason: missing [quote] tags

  6. #6
    Join Date
    Feb 2008
    Posts
    79
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default 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?

  7. #7
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Designer produces invalid code?

    Quote Originally Posted by Tiansen View Post
    jpn, so this means QPixmap does not originate from QObject either?
    QPixmap is not GUI component. QPixmap only represents image data.

    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.
    J-P Nurmi

  8. #8
    Join Date
    Feb 2008
    Posts
    79
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default 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!

Similar Threads

  1. Replies: 80
    Last Post: 12th March 2020, 14:58
  2. Client/Server Error: BadIDChoice
    By 3nc31 in forum Qt Programming
    Replies: 5
    Last Post: 27th November 2007, 11:22
  3. Replies: 2
    Last Post: 27th June 2007, 11:23
  4. problem with linking
    By mickey in forum Qt Programming
    Replies: 49
    Last Post: 12th August 2006, 22:41

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.