问题标签 [qtablewidget]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
1216 浏览

c++ - QTableWidget;使用 celllChanged 信号

我是一名使用 Qt 开发工作 GUI 的学生程序员,我在使用 QTableWidget 时遇到了问题。我有一个由这个小部件制作的电子表格,它将各种值作为用户输入。我在此电子表格之外有一个 QLineedit 字段,需要在第 9 列中显示任何值的总和。在这种情况下,我认为最好使用cellchanged 信号将第 9 列相加并显示将 linedit 字段设置为所有这些单元格的总和。我的问题是当我去执行我的应用程序时,我收到以下应用程序输出,而我的 GUI 中的这部分不起作用:

我已经多次确保这个插槽确实存在并且据我所知正确调用。但是我是一名学生,也许我不对,现在我在这里。

我的 InjectionDialog.h 包含以下插槽;

我的 injectiondialog.cpp 包含以下内容。

我的注入对话框还包括我添加此列的功能;如下:

这个问题可能是由我没有看到的一些简单的事情引起的。感谢您提供的任何帮助。请只留下建设性的反馈,因为我只对改进和实现我的目标感兴趣。在这方面,我感谢所有帮助并感谢您阅读本文的尝试。

0 投票
1 回答
13182 浏览

qt - 如何防止用户调整 QTableWidget 的列大小?

我想亲自管理表格中列的宽度,但是在从代码调整它们的大小后,我无法找到一种方法来阻止用户手动调整它们的大小。我发现它QTableViewcolumnResized()插槽,我看到的唯一方法是QTableWidget在计时器事件上一次又一次地对列进行子类化或调整大小。

可能有更简单的方法吗?

0 投票
1 回答
710 浏览

visual-studio-2010 - Qt QTableWidget Header Color

I would like to change the color of a vertical header cell in a QTableWidget.

Here is my (failed) attempt:

I have no idea why this wouldn't work.

0 投票
1 回答
10050 浏览

c++ - How to import a CSV file to a QTableWidget

I am student programmer and I am using Qt to develop a GUI interface for work and Im having trouble figuring out how I should make this this import function work. A bit of programmers writers block if you will. SO far I have this for code:

The issue here is that I don't know how to get the settext of each item in the table to reference the next item in the rowData QStringList. I need to increment by one location but I cant use a int++ because that will eventually look for a item in the QStringList that doesn't exist and cause a segmentation fault. I also cant use a for loop to cap the number I need in the location field here because of the current for loops structure. I just cant think of a good strategy for to approach this on. Please only leave constructive comments as I am only interested in learning or accomplishing this task. Thanks for reading!

0 投票
2 回答
5787 浏览

python - 在 PyQT4 中上下移动行

考虑一个 QTableWidget 和两个按钮“上移”和“下移”。点击上移,当前行应该上移一行,类似于“下移”。

实现相应的上移和下移功能最简单的方法是什么?

0 投票
1 回答
1301 浏览

c++ - Qt 中 QTableWidget 中的堆使用情况

我试图强调我的程序,它基本上用不同数量的行更新 QTableWidget

每次我做一些动作时,我都想修改表格的大小,但在它之前如果想清除它并用它来清除它的单元格内容。

我正在经历的是,从我的资源监视器监控的堆只会增加。

这是我在应用程序中按下按钮时运行的部分代码:

从 指定的行数 int nrows是一个非常可变的数字(从 10 到 10^5 )。

如何从堆中完全清除内存?

0 投票
1 回答
3887 浏览

python - 滚动 QTableWidget 到特定列

我在 QTableWidget 中有一堆数据,我希望能够滚动到特定列。我目前正在使用 scrollToItem(self.item(0, col))。但是,这会将行硬编码为 0。如果用户正在查看第 100 行并滚动到特定列,则会导致问题,因为它失去了在表格中的垂直位置。

有没有办法在 QTableWidget 提供的 QScrollArea 中找到用户当前正在查看的行?如果是这样,我可以轻松地用正确的行替换该默认行。

也许还有另一种方法可以使用 .ensureWidgetVisible() 之类的方法来实现此结果?但是,我不确定如何获得想要滚动到或使其可见的正确小部件。

0 投票
1 回答
6701 浏览

python - PySide/PyQt 中 QTableWidget 的 QMenu

这是我的问题详细信息:我有这些小部件 - QMenuBar、QTableWidget 和 QToolbar。这是我的代码示例:

问题是:例如,如何使 QMenu 像 Microsoft Excel 中一样(我的意思是仅添加/删除行/列)。提前致谢。

0 投票
1 回答
983 浏览

python - QTableWidget 中的 QComboBox 返回 NoneType

在我的一个应用程序中,我需要在 QTableWidget 中有一个 QComboBox。

我写了这段代码:

它正确地添加了 QComboBox。

但是,当我尝试使用 self.ui.listOfGoals.item(r,1) 检索此 QComboBox 时,会返回 None。

我还是 PyQt 的新手,所以我可能在这里错过了一些东西。有什么建议么?

0 投票
1 回答
2868 浏览

qtableview - 使用 QTableWidget / QTableView 滚动时锁定列?

当我在 QTableWidget / QTableView 中水平滚动时,是否可以保持一列的位置?

谢谢 !