You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Sunday, February 15th 2009, 5:27pm

Table drawing

Hi to all!


I need some help in order to draw a table. This table has data that come from some calculations. And I need a way to show this table as an image.

How can I do this ... ? with QImage or QPainter?
KUbuntu Jaunty Jacklope 9.04 [AMD64]

This post has been edited 1 times, last edit by "Nisok" (Feb 16th 2009, 5:31pm)


2

Monday, February 16th 2009, 5:32pm

Hey guys...

Not even one reply?! I changed the title in order to be more helpful. Pls I need some help..
KUbuntu Jaunty Jacklope 9.04 [AMD64]

3

Tuesday, February 17th 2009, 8:53am

If I understand correctly, you have a table widget and you want to capture the image. You can use QPixmap::grabWidget() for this purpose. Here is an example that saves the table to a bitmap file :

Source code

1
2
3
4
5
6
7
8
9
QPixmap originalPixmap = QPixmap::grabWidget(tableWidget);
QFileDialog dialog(this, Qt::Dialog);
dialog.setDefaultSuffix("bmp");
dialog.setFilters(QStringList() << "BMP image (*.bmp)");
dialog.setAcceptMode(QFileDialog::AcceptSave);
if (dialog.exec()) {
	QString fileName = dialog.selectedFiles().first();	
	originalPixmap.save(fileName, "BMP", 100);
}
Mandriva Linux release 2009.0 (Official) for i586
Kernel 2.6.27.10-desktop-1mnb on a Dual-processor i686

4

Tuesday, February 17th 2009, 11:26am

grabWidget(

Thank you very much for your reply. It seems that you understood my problem correctly... I will try your suggestion but I think that there won't be any problems.

Just in any case I give some more information about the question. I calculate a table which I want to draw on a widget as an image. And when the calculations change the table the image should be update, too.
KUbuntu Jaunty Jacklope 9.04 [AMD64]