Displaying an image in the QDataTable::paintField with QLabel. Is it possible?
Dear friends.... I am writing a database application with Qt 3.2 and SuSE 9.1. Each sales must write a report for the sales supervisor after the sales call a customer. one of the field in the report content a smiley (image file) to represent(describe) the reaction of the customer. The smiley field has content in the form of ascii art such as : ":(", ":-)", ":X" etc. The sales reports are displayed in QDataTable. But I want the sales supervisor does not see the ascii art but the corresponded image file which stored in a subdirectory of my database application. So my code should change for example ":)" into the file "1.png". I want to use this : void QDataTable::paintField ( QPainter * p, const QSqlField * field, const QRect & cr, bool selected ) [virtual protected] I plotted the QDataTable in a UI Form with QtDesigner. Is it possible to draw an image file into QDataTable with QLabel instead of QPainter ? If yes, how? I have second question, if the form an sql query (content ascii art like this : ":)" why this code comes with error ? QString noapp = noapplineEdit.text(); //nomor appointment QString sid = sidlineEdit.text(); //SalesID QString cid = cidlineEdit.text(); //Customer ID QString smiley = slineEdit.text(); //Smiley in ascii art QString report = rlineEdit.text(); //report dalam kalimat biasa QString reportsales = QString (insert into sales report(nomerappointment, salesid, custid, smiley, report) values('%1', '%1', '%1', '%1', '%1') .arg(noapp) .arg(sid) .arg(cid) .arg(smiley) .arg(report); In PHP I can use "\" so I make like this : $smiley = "\:)" but should I do in C++ (Qt)? Thank you very much in advance. __________________________________ Do you Yahoo!? New and Improved Yahoo! Mail - 100MB free storage! http://promotions.yahoo.com/new_mail
On Friday 24 September 2004 15:30, Prabu Subroto wrote:
Dear friends....
I am writing a database application with Qt 3.2 and SuSE 9.1.
Each sales must write a report for the sales supervisor after the sales call a customer. one of the field in the report content a smiley (image file) to represent(describe) the reaction of the customer.
The smiley field has content in the form of ascii art such as : ":(", ":-)", ":X" etc.
The sales reports are displayed in QDataTable.
But I want the sales supervisor does not see the ascii art but the corresponded image file which stored in a subdirectory of my database application. So my code should change for example ":)" into the file "1.png".
I want to use this : void QDataTable::paintField ( QPainter * p, const QSqlField * field, const QRect & cr, bool selected ) [virtual protected]
Why do it the hard way? QDataTable is derived from QTable where you can simply set a pixmap in a cell: http://doc.trolltech.com/3.3/qtable.html#setPixmap
Is it possible to draw an image file into QDataTable with QLabel instead of QPainter ?
You don't even need a QLabel - see above.
I have second question, if the form an sql query (content ascii art like this : ":)" why this code comes with error ?
QString noapp = noapplineEdit.text(); //nomor appointment QString sid = sidlineEdit.text(); //SalesID QString cid = cidlineEdit.text(); //Customer ID QString smiley = slineEdit.text(); //Smiley in ascii art QString report = rlineEdit.text(); //report dalam kalimat biasa QString reportsales = QString (insert into sales report(nomerappointment, salesid, custid, smiley, report) values('%1', '%1', '%1', '%1', '%1') .arg(noapp) .arg(sid) .arg(cid) .arg(smiley) .arg(report);
In PHP I can use "\" so I make like this : $smiley = "\:)" but should I do in C++ (Qt)?
QString smiley = "\\:)";
Note the double backslash. Only one backslash indicates the beginning of an
escape sequence - the compiler then expects a predefined sequence like "\n"
or an octal character specification like "\123". If you want a literal
backslash, use "\\".
CU
--
Stefan Hundhammer
Hallo Stefan....
Hier bin ich der Dummer Programmierer....
I want to change the "ascii art" as the field value of
emoicon. like ":)" into "images/1.png" .
As a try, I did like this :
void funonseqForm::retsejarahSlot()
{
QString stringsql = QString("select salesid, fcr,
report, emoicon, callduration, timestamp from
salesreport where custid=%1").arg(cid);
cur = new QSqlSelectCursor(stringsql, bd);
hisdataTable->setSqlCursor(cur, true, false);
hisdataTable->setNullText(" ");
hisdataTable->setColumn(0, "salesid", "Berater
ID");
hisdataTable->setColumn(1, "fcr", "FCR");
hisdataTable->setColumn(2, "report", "Report");
hisdataTable->setColumn(3, "emoicon", "EmoIcon");
hisdataTable->setColumn(4, "callduration", "Anruf
Dauer");
hisdataTable->setColumn(5, "timestamp", "Time
Stamp");
//QLabel * p = new QLabel(this);
//p->setPixmap(QPixmap("images/1.png"));
//p->setAutoResize(true);
hisdataTable->setPixmap(1, 2,
QPixmap("images/1.png"));
hisdataTable->refresh();
}
But in compilation I got this error message :
patrixlinux@patrix:~/arsip/proyek/qt/kvclient> make
qmake -o Makefile kvclient.pro
g++ -c -pipe -O2 -march=i586 -mcpu=i686
-fmessage-length=0 -Wall -fPIC -Wall -W -O2
-march=i586 -mcpu=i686 -fmessage-length=0 -Wall -fPIC
-D_REENTRANT -DQT_NO_DEBUG -DQT_THREAD_SUPPORT
-DQT_SHARED -DQT_TABLET_SUPPORT
-I/usr/lib/qt3/mkspecs/default -I. -I. -I/usr/include
-I/usr/lib/qt3/include -I.ui/ -I.moc/ -o
.obj/funonseqform.o .ui/funonseqform.cpp
In file included from .ui/funonseqform.cpp:37:
/usr/lib/qt3/include/qdatatable.h: In member function
`virtual void funonseqForm::retsejarahSlot()':
/usr/lib/qt3/include/qdatatable.h:212: error: `virtual
void QDataTable::setPixmap(int, int, const QPixmap&)'
is protected
funonseqform.ui.h:111: error: within this context
make: *** [.obj/funonseqform.o] Error 1
patrixlinux@patrix:~/arsip/proyek/qt/kvclient>
Please tell me why...
Thank you very much.
ps. hisdataTable is a QDataTable.
--- Stefan Hundhammer
Dear friends....
I am writing a database application with Qt 3.2 and SuSE 9.1.
Each sales must write a report for the sales supervisor after the sales call a customer. one of
On Friday 24 September 2004 15:30, Prabu Subroto wrote: the
field in the report content a smiley (image file) to represent(describe) the reaction of the customer.
The smiley field has content in the form of ascii art such as : ":(", ":-)", ":X" etc.
The sales reports are displayed in QDataTable.
But I want the sales supervisor does not see the ascii art but the corresponded image file which stored in a subdirectory of my database application. So my code should change for example ":)" into the file "1.png".
I want to use this : void QDataTable::paintField ( QPainter * p, const QSqlField * field, const QRect & cr, bool selected ) [virtual protected]
Why do it the hard way?
QDataTable is derived from QTable where you can simply set a pixmap in a cell:
http://doc.trolltech.com/3.3/qtable.html#setPixmap
Is it possible to draw an image file into QDataTable with QLabel instead of QPainter ?
You don't even need a QLabel - see above.
I have second question, if the form an sql query (content ascii art like this : ":)" why this code comes with error ?
QString noapp = noapplineEdit.text(); //nomor appointment QString sid = sidlineEdit.text(); //SalesID QString cid = cidlineEdit.text(); //Customer ID QString smiley = slineEdit.text(); //Smiley in ascii art QString report = rlineEdit.text(); //report dalam kalimat biasa QString reportsales = QString (insert into sales report(nomerappointment, salesid, custid, smiley, report) values('%1', '%1', '%1', '%1', '%1') .arg(noapp) .arg(sid) .arg(cid) .arg(smiley) .arg(report);
In PHP I can use "\" so I make like this : $smiley = "\:)" but should I do in C++ (Qt)?
QString smiley = "\\:)";
Note the double backslash. Only one backslash indicates the beginning of an escape sequence - the compiler then expects a predefined sequence like "\n" or an octal character specification like "\123". If you want a literal backslash, use "\\".
CU -- Stefan Hundhammer
Penguin by conviction. YaST2 Development SuSE Linux AG Nuernberg, Germany -- To unsubscribe, email: suse-programming-e-unsubscribe@suse.com For additional commands, email: suse-programming-e-help@suse.com Archives can be found at: http://lists.suse.com/archive/suse-programming-e
__________________________________ Do you Yahoo!? Yahoo! Mail Address AutoComplete - You start. We finish. http://promotions.yahoo.com/new_mail
On Monday 27 September 2004 15:29, Prabu Subroto wrote:
In file included from .ui/funonseqform.cpp:37: /usr/lib/qt3/include/qdatatable.h: In member function `virtual void funonseqForm::retsejarahSlot()': /usr/lib/qt3/include/qdatatable.h:212: error: `virtual void QDataTable::setPixmap(int, int, const QPixmap&)' is protected
The compiler unfortunately is right (of course, it always is, wiseass that it
is... ;-) ): QDataTable::setPixmap() is a protected member function.
I consider that a design flaw of that class: QDataTable::setText() is public,
QDataTable::setPixmap() is not. The Qt doc seems to be wrong this time. :-(
Workaround:
You can either subclass your class from QDataTable or, if this is not an
option, subclass QDataTable to another class that as a public setPixmap()
method that simply calls QDataTable::setPixmap().
CU
--
Stefan Hundhammer
Uffhhh....
Liebe Stefan.
Stefan, I think I should try subclassing a QLabel from
QDataTable.
But I don't know how I should do that.
Could you give me a very example for subclassing
QLabel into QDataTable so I can do drawing an image
file in the QDataTable.
I can not understand the example code from
doc.trolltech.com . It's too complicated for me.
Thank you very much in advance,
--- Stefan Hundhammer
On Monday 27 September 2004 15:29, Prabu Subroto wrote:
In file included from .ui/funonseqform.cpp:37: /usr/lib/qt3/include/qdatatable.h: In member function `virtual void funonseqForm::retsejarahSlot()': /usr/lib/qt3/include/qdatatable.h:212: error: `virtual void QDataTable::setPixmap(int, int, const QPixmap&)' is protected
The compiler unfortunately is right (of course, it always is, wiseass that it is... ;-) ): QDataTable::setPixmap() is a protected member function. I consider that a design flaw of that class: QDataTable::setText() is public, QDataTable::setPixmap() is not. The Qt doc seems to be wrong this time. :-(
Workaround:
You can either subclass your class from QDataTable or, if this is not an option, subclass QDataTable to another class that as a public setPixmap() method that simply calls QDataTable::setPixmap().
CU -- Stefan Hundhammer
Penguin by conviction. YaST2 Development SuSE Linux AG Nuernberg, Germany -- To unsubscribe, email: suse-programming-e-unsubscribe@suse.com For additional commands, email: suse-programming-e-help@suse.com Archives can be found at: http://lists.suse.com/archive/suse-programming-e
__________________________________ Do you Yahoo!? New and Improved Yahoo! Mail - 100MB free storage! http://promotions.yahoo.com/new_mail
On Monday 27 September 2004 16:59, Prabu Subroto wrote:
Stefan, I think I should try subclassing a QLabel from QDataTable. But I don't know how I should do that.
???
Neither do I. That would neither make sense nor would it work.
What you need to do is to subclass your own widget class from QDataTable and
make the setPixmap() method publicly available - like this:
MyDataTable: public QDataTable
{
Q_OBJECT
MyDataTable( QWidget * parent = 0, const char * name = 0 )
: QDataTable( parent, name ) // call parent class constructor
{} // nothing more to do here
virtual ~MyDataTable() {} // empty virtual destructor (you want that!)
// this is what we need this class for in the first place:
// make this method public
setPixmap( int row, int col, const QPixmap & pix )
{ QTable::setPixmap( row, col, pix ); }
}
That's it. Now you can setPixmap() from the outside.
CU
--
Stefan Hundhammer
Argh - stupid me - I missed the most important part: On Tuesday 28 September 2004 11:33, Stefan Hundhammer wrote:
{ Q_OBJECT
public:
MyDataTable( QWidget * parent = 0, const char * name = 0 ) : QDataTable( parent, name ) // call parent class constructor
Otherwise everything would be private. Sorry.
CU
--
Stefan Hundhammer
participants (2)
-
Prabu Subroto
-
Stefan Hundhammer