PDA

View Full Version : x11,about qwidget::repaint()



calmspeaker
7th December 2009, 02:28
Hi all
I use QTableView,QTableModel(inherit QAbstractTableModel)to display data.
Every second, I change the background color in model and emit signal.In the slot, I use tableview->viewPort()->repaint() to repaint the tableview.

In windows, the program works well. But in x11(suse), the background color does not change at all.

Please give a clue! Thank you in advance.


ps: I use qApp->processEvents() after tableview->viewPort()->repaint().But has no effect.In qt assistant there is int QApplication::x11ProcessEvent ( XEvent * ), but I do not know how to use it. what is a xevent?

calmspeaker
7th December 2009, 08:04
I also tried this way:
emit dataChanged(this->index(0,0),this->index(this->rowCount(),0));
But it cannot repaint the tableview immediately in windows XP( cannot get the "Blink" result!) and it did not repaint the tableview at all int SUSE.

calmspeaker
7th December 2009, 13:54
I make a small piece of code, the pro works well in windows xp(compile by vc2008) and does not work in SUSE(compile by gcc)

calmspeaker
8th December 2009, 02:22
I just tried the code in solaris,it works either. :confused:
Now, the question is, the code works in windows xp,solaris, does not work in SUSE.
If my way cannot go through,can anybody tell me that how to change the background color of column of QTableView every second which works in SUSE,solaris,windowsXP?

calmspeaker
9th December 2009, 04:18
Hi all
I use QTableView,QTableModel(inherit QAbstractTableModel)to display data.
Every second, I change the background color in model and emit signal.In the slot, I use tableview->viewPort()->repaint() to repaint the tableview.

In windows, the program works well. But in x11(suse), the background color does not change at all.

Please give a clue! Thank you in advance.


ps: I use qApp->processEvents() after tableview->viewPort()->repaint().But has no effect.In qt assistant there is int QApplication::x11ProcessEvent ( XEvent * ), but I do not know how to use it. what is a xevent?

I use QTableView and TableModel (not QTableModel)
是谁导演这场戏,在这孤单角色里。。。。。

Tanuki-no Torigava
9th December 2009, 06:38
Hi all
I use QTableView,QTableModel(inherit QAbstractTableModel)to display data.
Every second, I change the background color in model and emit signal.In the slot, I use tableview->viewPort()->repaint() to repaint the tableview.

In windows, the program works well. But in x11(suse), the background color does not change at all.

Please give a clue! Thank you in advance.


ps: I use qApp->processEvents() after tableview->viewPort()->repaint().But has no effect.In qt assistant there is int QApplication::x11ProcessEvent ( XEvent * ), but I do not know how to use it. what is a xevent?

Hi, X11 is *NIX GUI core.So X11 events are *NIX GUI core events. Qt operates on top of that. Also the code for MS and *NIX is a bit different. You can read that in assistant. And why do you need to repaint so frequently? You can use repaint only cell changes, not the whole table. If it will run slow then you can try QGraphicsView.

Best regards.

calmspeaker
9th December 2009, 06:47
Hi, X11 is *NIX GUI core.So X11 events are *NIX GUI core events. Qt operates on top of that. Also the code for MS and *NIX is a bit different. You can read that in assistant. And why do you need to repaint so frequently? You can use repaint only cell changes, not the whole table. If it will run slow then you can try QGraphicsView.

Best regards.

Becasue I need to remind the user of the information(the alarm of the scada system) .
I am also considering that repaint the first column of the tableview to reduce the cost of cpu.But now there is a more serious problem as you know.

I just looked into the assistant. But nothing I got.

calmspeaker
9th December 2009, 07:50
the problem is solved.
The reason is: bool m_change is not initalized. In gcc, m_change = !change cannot change the m_change's value.

Thanks all.