qt4

PyQT4: Adding combobox in Qtableview

左心房为你撑大大i 提交于 2019-12-18 17:06:13
问题 I am new to PyQT. I am interested to add a combobox to the each row of tableView. Is it possible in PyQT 4? I know, it is possible in QT5, but not sure about PyQT. Thank you in advance for help. 回答1: Does this need to be done using a QTableView or can you do it using a QTableWidget? Making the assumption that you can use the Widget vs the View, you can easily add a combobox (or any widget) to a cell. class MainWindow(QtGui.QMainWindow): def __init__(self, parent=None): QtGui.QMainWindow._

How do I use QTextBlock?

荒凉一梦 提交于 2019-12-18 16:53:46
问题 I'm completely new to C++ and Qt. I want to populate a QTextEdit object with QTextBlocks , how do I do that? e.g. If I have the sentence "the fish are coming" how would I put each word into its own QTextBlock and add that block to QTextEdit , or have I misunderstood how QTextBlock actually works? 回答1: QTextEdit will let you add your contents via a QString : QTextEdit myEdit("the fish are coming"); It also allows you to use a QTextDocument , which holds blocks of text. The QTextDocument itself

Checkbox in a header cell in QTableView

╄→гoц情女王★ 提交于 2019-12-18 16:47:15
问题 I want to have a simple column header with a checkbox that selects/ deselects all rows in a QTableView. Clicking the check box in the header causes either to select or deselect all rows. When I want to add a check box in a table cell, I have to just return the check state for the Qt::CheckStateRole in the data(..) for the required model indices as below. This is working as expected. QVariant MyModel::data( const QModelIndex & rIndex, int iRole) const { ... if (iRole == Qt::Qt::CheckStateRole)

When setting the WA_DeleteOnClose attribute on a Qt MainWindow, the program crashes when deleting the ui pointer

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-18 16:46:09
问题 I have set the WA_DeleteOnClose widget attribute in a MainWindow. setAttribute(Qt::WA_DeleteOnClose); However, whenever I close that main window, I get a segfault in its destructor, which only has delete ui; In a nutshell, created a Qt4 GUI Application in Creator, added the setAttribute(Qt::WA_DeleteOnClose); to constructor, program now crashes on exit. 回答1: Are you getting a segfault in its destructor the first time, or the second time? Remember that your main window destructor should run

Best crossplatform C++/QT4 development environment

試著忘記壹切 提交于 2019-12-18 16:45:50
问题 I would like to develop cross-platform applications using C++ and QT4. I code on both Linux and Windows (MinGW). Currently I'm using KDevelop and it's QMake integration. On Windows I'm trying out Eclipse with QT integration plugin. However moving sources and updating profiles/IDE project files on both systems is tedious. I'm looking into using CMake as it can generate Makefiles, KDevelop project files and Eclipse project files. What's your opinion? What are you using for such kind of

How to use QPainter on QPixmap

寵の児 提交于 2019-12-18 14:52:18
问题 I'm a newbie to Qt/Embedded. I want to use QPainter to draw stuff on a QPixmap , which will be added to QGraphicsScene . Here is my code. But it does not show the drawings on the pixmap. It shows only the black pixmap. int main(int argc, char **argv) { QApplication a(argc, argv); QMainWindow *win1 = new QMainWindow(); win1->resize(500,500); win1->show(); QGraphicsScene *scene = new QGraphicsScene(win1); QGraphicsView view(scene, win1); view.show(); view.resize(500,500); QPixmap *pix = new

How to use QPainter on QPixmap

余生颓废 提交于 2019-12-18 14:52:02
问题 I'm a newbie to Qt/Embedded. I want to use QPainter to draw stuff on a QPixmap , which will be added to QGraphicsScene . Here is my code. But it does not show the drawings on the pixmap. It shows only the black pixmap. int main(int argc, char **argv) { QApplication a(argc, argv); QMainWindow *win1 = new QMainWindow(); win1->resize(500,500); win1->show(); QGraphicsScene *scene = new QGraphicsScene(win1); QGraphicsView view(scene, win1); view.show(); view.resize(500,500); QPixmap *pix = new

Showing a .gif animation in QLabel

北战南征 提交于 2019-12-18 13:14:16
问题 I would like to show a .gif animation in a QLabel widget, alongside text. The following code won't work: self.status_txt = QtGui.QLabel('Loading... <img src="etc/loading.gif">') as the image won't animate. I tried achiving it by using a QMovie object: self.status_txt = QtGui.QLabel("Loading...") movie = QtGui.QMovie("etc/loading.gif") self.status_txt.setMovie(movie) movie.start() But then I can't put the animation and the text together. Is there a different solution besides using two

PySide Qt: Auto vertical growth for TextEdit Widget, and spacing between widgets in a vertical layout

房东的猫 提交于 2019-12-18 13:13:41
问题 I need to Solve two problems With my widget above. I'd like to be able to define the amount of space put between the post widgets shown in the image (they look fine as is, but I wanna know it's done). I'd like to grow the text edits vertically based on the amount of text they contain without growing horizontally. For 1 the code that populates the widgets is as follows : self._body_frame = QWidget() self._body_frame.setMinimumWidth(750) self._body_layout = QVBoxLayout() self._body_layout

destructors in Qt4

泪湿孤枕 提交于 2019-12-18 13:07:54
问题 I'm very confused about using destructors in Qt4 and hope, you guys can help me. When I have a method like this (with "Des" is a class): void Widget::create() { Des *test = new Des; test->show(); } how can I make sure that this widget is going to be deleted after it was closed? And in class "Des" i have this: Des::Des() { QPushButton *push = new QPushButton("neu"); QHBoxLayout *layout = new QHBoxLayout; layout->addWidget(push); setLayout(layout); } where and how do I have to delete *push and