[Interest] Showing Icon and tooltip into QSqlQueryModel index
Thales Lange
thaleslange at gmail.com
Mon Feb 20 15:24:33 CET 2012
Michele,
I attached an example. This example contains:
1) SQL script to create the schema.
2) Example code
3) A picture that shows the result (The example adds a warning icon and
a tooltip message on the first column).
The example uses the MySQL Driver.
Best Regards,
Thales Lange.
On 20-02-2012 10:55, Michele Ciampichetti wrote:
> Thanks Thales but, I've no idea how can I do this :(
>
> could you provide me any example for do this?
>
> Thanks a lot!
>
> Michele
>
> 2012/2/19 Thales Lange <thaleslange at gmail.com
> <mailto:thaleslange at gmail.com>>
>
> Hi Michele.
>
> I think you will need to inherit QSqlQueryModel and reimplement the
> method:
>
> virtual QVariant data(const QModelIndex &item, int role =
> Qt::DisplayRole ) const
>
> When "item" is your table index and role == Qt::DecorationRole, you can
> return the desirable icon.
>
> I hope this solution might be useful!
>
> Best Regards,
> Thales Lange.
>
>
> On 19-02-2012 12:16, Michele Ciampichetti wrote:
> > Dear to all,
> > I need to insert an icon into every index of a QSqlQueryModel (so I
> > can retrieve them from DB but mark them with the icon).
> > I need something like QStandardItem (const QIcon &icon, const QString
> > &text) constructor, but I don't know how can I subclass It.
> > I need also to activate the tooltip on some columns.
> >
> > I tried to see something of code of QSqlQueryModel and the structure
> > of model classes but I'm a beginner and i lose myself on it :(
> >
> > Why each model have more classes nested on it? There is a
> > QSqlQueryModelPrivate, QSqlQueryModelItem ecc. How can use it? :(
> > Could you send a small example or more documentation of this?
> >
> > Thanks for your time
> >
> > Michele
> > _______________________________________________
> > Interest mailing list
> > Interest at qt-project.org <mailto:Interest at qt-project.org>
> > http://lists.qt-project.org/mailman/listinfo/interest
> >
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: example.zip
Type: application/zip
Size: 31620 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120220/fbef3314/attachment.zip>
More information about the Interest
mailing list