在表格视图、模型中,当你点击单元格时,你知道单元格行列的方法是什么?
版本:
PyQt : 4.11.4
Python : 3.5.3
这些是我对表视图、模型的设置。
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.ntableView = QtGui.QTableView()
self.nlayout = QtGui.QVBoxLayout()
self.nmodel = QtGui.QStandardItemModel()
self.ntableView.setModel(self.nmodel)
self.nlayout.addWidget(self.ntableView)
self.setLayout(self.nlayout)
self.func_mappingSignal()
def func_mappingSignal(self):
self.ntableView.clicked.connect(self.func_test)
def func_test(self, item):
# http://www.python-forum.org/viewtopic.php?f=11&t=16817
cellContent = item.data()
print(cellContent) # test
sf = "You clicked on {}".format(cellContent)
print(sf)
Run Code Online (Sandbox Code Playgroud) int* dec2bin(int y){
int *arr = (int*)malloc(sizeof(int)*5);
int i;
for (i=0; i<5; i++) arr[i]=0;
return arr;
}
Run Code Online (Sandbox Code Playgroud)
这是函数dec2bin的一部分.
在这段代码,我做的arr[0]到arr[4]的一切0.
但是这个函数返回值1070192.我想回来00000.
我该怎么做才能解决这个问题?
using UnityEngine;
using System.Collections;
public class GameRootScript : MonoBehaviour {
public GameObject prefab = null;
private AudioSource audio;
public AudioClip jumpSound;
public Texture2D icon = null;
public static string mes_text = "test";
// Use this for initialization
void Start () {
this.audio = this.gameObject.AddComponent<AudioSource> ();
this.audio.clip = this.jumpSound;
this.audio.loop = false;
}
void onGUI()
{
Debug.Log ("Image");
GUI.DrawTexture (new Rect (Screen.width/2, 64, 64, 64), icon);
GUI.Label (new Rect (Screen.width / 2, 128, 128, 32), mes_text);
}
// Update is called …Run Code Online (Sandbox Code Playgroud)