Results 1 to 7 of 7

Thread: MyQImage Class

  1. #1
    Join Date
    Nov 2009
    Posts
    15
    Qt products
    Qt4
    Platforms
    Windows

    Default MyQImage Class

    Hi,
    I want to create my own Class of QImage type, but I've found an error:

    Error C2664: 'QImage::QImage(const char *const [])' : can not convert parameter 1 from 'QWidget *' to 'const char *const []'


    class MiQImage : public QImage
    {
    Q_OBJECT
    public:
    MiQImage(QWidget* parent);
    };

    MiQImage::MiQImage(QWidget* parent) : QImage(parent)
    {

    };

    Any idea why it's wrong? Thanks!

  2. #2
    Join Date
    Jul 2009
    Posts
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: MyQImage Class

    Quote Originally Posted by TeresaML View Post
    Hi,
    Error C2664: 'QImage::QImage(const char *const [])' : can not convert parameter 1 from 'QWidget *' to 'const char *const []'

    MiQImage::MiQImage(QWidget* parent) : QImage(parent)
    {

    };
    QImage takes e.g. filename as parameter not QWidget.
    remove parent parameter from QImage constructor call.

    like:
    MiQImage::MiQImage(QWidget* parent) : QImage()
    {

    };

  3. #3
    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: MyQImage Class

    Could you explain why do you want to subclass QImage? I can hardly find a reason to do that.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Nov 2009
    Posts
    15
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: MyQImage Class

    I've have created my own class (MiQImage), with the class QImage in it, for two main reasons (correct me if I am wrong on any of these points, please):

    - I want to instantiate a variable of the class MiQImage in the class MiQDialog. In this way, the variable will be visible for all the functions implemented in MiQDialog.
    - I will add some features in the class MiQImage, which are not possible only with the class MiQImage (zoomin, zoomout,..).

    I think it is a good solution, but I am newbie on this, so any suggestion or correction is very welcome.

    Best Regards

  5. #5
    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: MyQImage Class

    QImage is nothing that is visible. It's just a structure of data tailored to hold an image. If you want to show an image on the screen, you will need QLabel or QGraphicsView with QGraphicsPixmapItem. If you want zooming and stuff, the latter might prove better - but you have to decide based on what you intend to use the image for.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Nov 2009
    Posts
    15
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: MyQImage Class

    When I said "......", I meant visible for the functions: the functions implemented may use the variable of the class MiQImage

  7. #7
    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: MyQImage Class

    Ah, ok... anyway I don't think subclassing QImage will do you much good here. Every operation you perform on the image will have to return a copy of the image anyway (you can't "zoom" an image, you have to crop it and scale it and both these operations return copies of the original image) so it might prove easier if you just placed your extra methods in the dialog class if that's the only place you will be accessing your images. If you insist on subclassing QImage, remember it is not a QObject, so no Q_OBJECT macro and no passing objects as parents. You also can't make QImage a QObject because QObjects can't be copied.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. QT Class GUI Interactions??
    By mikey33 in forum Newbie
    Replies: 3
    Last Post: 19th November 2009, 02:01
  2. Joomla 1.5 password hash Class 1.0 for QT using C++
    By RajabNatshah in forum Qt Programming
    Replies: 0
    Last Post: 6th October 2009, 15:49
  3. Extending two class "the same way"
    By caduel in forum General Programming
    Replies: 3
    Last Post: 22nd July 2009, 22:55
  4. class QHBoxLayout
    By csvivek in forum Installation and Deployment
    Replies: 2
    Last Post: 10th April 2008, 07:57
  5. Replies: 2
    Last Post: 4th May 2006, 19:17

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.