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