Results 1 to 7 of 7

Thread: Example HowTo create custom view

  1. #1
    Join Date
    Jun 2006
    Posts
    9
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Example HowTo create custom view

    Hello,

    i have the Problem that i want to have a custom view. Thing is, i want to display detail information of data that is held in a table. My assumption is to derive from QAbstractItemView ... but i do not know exactly how ....

    Let's say we do have 6 entities. the table shows 2 of them. Now when i click the "row number" (some QHeaderView thing) i want to open a window that displays all 6 entities using QLabel componets.

    So i did the layout using designer, and am trying to subclass QAbstractItemView. But i do receive lot of "No such slots" errors. Has anyone an idea/pointer/code example on how such things are done?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Example HowTo create custom view

    Quote Originally Posted by dexjam
    But i do receive lot of "No such slots" errors.
    Could you post the exact error messages? Maybe you forgot to add Q_OBJECT macro?

    Quote Originally Posted by dexjam
    Has anyone an idea/pointer/code example on how such things are done?
    I guess you want to implement something like this: http://doc.trolltech.com/4.2/qdatawidgetmapper.html (note that this class is from Qt 4.2).

  3. #3
    Join Date
    Jun 2006
    Posts
    9
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: Example HowTo create custom view

    The exact error message is

    Qt Code:
    1. Object::connect: No such slot CertInfoView::rowsInserted(QModelIndex,int,int)
    2. Object::connect: No such slot CertInfoView::rowsAboutToBeRemoved(QModelIndex,int,int)
    3. Object::connect: No such slot CertInfoView::_q_rowsRemoved(QModelIndex,int,int)
    4. Object::connect: No such slot CertInfoView::_q_columnsAboutToBeRemoved(QModelIndex,int,int)
    5. Object::connect: No such slot CertInfoView::_q_columnsRemoved(QModelIndex,int,int)
    6. Object::connect: No such slot CertInfoView::reset()
    7. Object::connect: No such slot CertInfoView::doItemsLayout()
    8. Object::connect: No such slot CertInfoView::selectionChanged(QItemSelection,QItemSelection)
    9. Object::connect: No such slot CertInfoView::currentChanged(QModelIndex,QModelIndex)
    To copy to clipboard, switch view to plain text mode 

    which is actually true because i did not implement these slots. Do i have to do this really?

    And yes, QDataWidgetMapper, seems to be exactly what i am looking for ...

    Great news, except that i would have to switch to Qt 4.2. Anyway, do you know how to do it using qt 4.1.3 ? Maybe the general idea is info enough ...

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Example HowTo create custom view

    Quote Originally Posted by dexjam
    which is actually true because i did not implement these slots. Do i have to do this really?
    These errors are a bit weird. These are not abstract slots --- they should be implemented in base classes. Maybe there's something wrong with your class definition? Do you use public inheritance?

    Quote Originally Posted by dexjam
    Great news, except that i would have to switch to Qt 4.2. Anyway, do you know how to do it using qt 4.1.3 ? Maybe the general idea is info enough ...
    Most likely this class doesn't use any mechanisms that aren't present in Qt 4.1. The only problem might be the licence under Qt 4.2 TP1 was released.

  5. #5
    Join Date
    Jun 2006
    Posts
    9
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: Example HowTo create custom view

    Quote Originally Posted by jacek
    These errors are a bit weird. These are not abstract slots --- they should be implemented in base classes. Maybe there's something wrong with your class definition? Do you use public inheritance?
    Yes i do use public inheritance with QAbstractItemView and QDialog. The Ui::Class is inherited private ...

    Am i doing sth. wrong?

    Quote Originally Posted by jacek
    Most likely this class doesn't use any mechanisms that aren't present in Qt 4.1. The only problem might be the licence under Qt 4.2 TP1 was released.
    So you mean i could simply copy this class into my sources ... if the license is ok of course ...

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Example HowTo create custom view

    Quote Originally Posted by dexjam
    Yes i do use public inheritance with QAbstractItemView and QDialog.
    The problem is that both QAbstractItemView and QDialog are widgets and all widgets inherit from QObject, so in this case your CertInfoView represents two different QObjects --- Qt doesn't use virtual inheritance from QObject.

    As a workaround you could create another class that represents a dialog with CertInfoView on it (this way the view won't have to inherit from QDialog).

    Quote Originally Posted by dexjam
    So you mean i could simply copy this class into my sources ... if the license is ok of course ...
    Well... not simply, because it uses some private Qt headers. You will have to merge QDataWidgetMapper with QDataWidgetMapperPrivate.

    Or just use the Heavy Inspiration(tm) technique, if the licence permits it.

  7. #7
    Join Date
    Jun 2006
    Posts
    9
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: Example HowTo create custom view

    Quote Originally Posted by jacek
    The problem is that both QAbstractItemView and QDialog are widgets and all widgets inherit from QObject, so in this case your CertInfoView represents two different QObjects --- Qt doesn't use virtual inheritance from QObject.

    As a workaround you could create another class that represents a dialog with CertInfoView on it (this way the view won't have to inherit from QDialog).
    Ok, thanks for the hint ....

Similar Threads

  1. Model - View Programming doubt.
    By munna in forum Qt Programming
    Replies: 4
    Last Post: 28th April 2006, 14:01
  2. How to create custom slot in Qt Designer 4.1?
    By jamadagni in forum Qt Tools
    Replies: 31
    Last Post: 18th January 2006, 21:46

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.