qtwidgets

How can I add more than one QAction to same QMenu?

左心房为你撑大大i 提交于 2021-01-27 23:30:25
问题 I'm trying to implement Qt Menus customization, and I'm giving a feature to add same QAction more than once in the same RMB context menu. But when I try to do: myMenu->addAction( myAction ); myMenu->addAction( myAction ); Adding QAction twice, only one instance of QAction appear on the menu. Why can't I have more than one instances of QAction ? Is there any trick to achieve this? I was trying to clone/create a new action with all the propeties of previous action. But I don't know the way to

Enable resizing on QWidget

别说谁变了你拦得住时间么 提交于 2020-12-12 03:18:38
问题 I want a resize feature in a QWidget using Qt, like the one shown in the image below. I have used following tried following ways: using QSizeGrip , setSizeGripEnabled 回答1: For completeness I'm showing two examples: with and without the Qt Designer. Example using Qt Designer Check the sizeGripEnabled property: Preview from within the Qt Designer ( Form > Preview... ): Minimal application to show the dialog: #include <QtWidgets/QApplication> #include <QDialog> #include "ui_DialogButtonBottom.h"

Enable resizing on QWidget

谁说胖子不能爱 提交于 2020-12-12 03:17:06
问题 I want a resize feature in a QWidget using Qt, like the one shown in the image below. I have used following tried following ways: using QSizeGrip , setSizeGripEnabled 回答1: For completeness I'm showing two examples: with and without the Qt Designer. Example using Qt Designer Check the sizeGripEnabled property: Preview from within the Qt Designer ( Form > Preview... ): Minimal application to show the dialog: #include <QtWidgets/QApplication> #include <QDialog> #include "ui_DialogButtonBottom.h"

How to alter Qt Widgets in WINAPI threads?

青春壹個敷衍的年華 提交于 2020-07-04 04:23:07
问题 I need to alter three progress bars simultaneously in three WINAPI threads. Since my funtions, that change value of progress bars are to have access to these bars, they are members of MainWindow class. So i created wrappers with signature that is required by CreateThread function, but I still get segmentation fault when I try to start my threads. What it can be caused by and how to handle this and get my code to work? Example of my function: DWORD MainWindow::ThreadFunc1() { for(int i = 0; i

pyQt: How do I update a label?

做~自己de王妃 提交于 2020-06-25 03:11:08
问题 I created this simple UI with qtDesigner and I want to update my label every 10 seconds with the value of a function, but I have no idea how to do this.I've tried different things but nothing worked. def example(): ... return text UI: class Ui_Form(object): def setupUi(self, Form): Form.setObjectName("Form") Form.resize(400, 300) self.label = QtWidgets.QLabel(Form) self.label.setGeometry(QtCore.QRect(165, 125, 61, 16)) self.label.setObjectName("label") self.retranslateUi(Form) QtCore

How to remove QTreeView indentation

拜拜、爱过 提交于 2020-01-13 16:27:25
问题 I want to have a QTreeView without an indentation on the left side increasing at each nesting level. I tried setting QTreeView::setIndentation(0) . It removes the indentations just as I want, however it also hides the tree arrows. Default behavior: With indentations ✗ With arrows ✔ After setIndentation(0) : Without indentations ✔ Without arrows ✗ Desired behavior: Without indentations ✔ With arrows ✔ So how can I achieve the result shown in the third example? Is there any standard way of

How to remove QTreeView indentation

帅比萌擦擦* 提交于 2020-01-13 16:27:18
问题 I want to have a QTreeView without an indentation on the left side increasing at each nesting level. I tried setting QTreeView::setIndentation(0) . It removes the indentations just as I want, however it also hides the tree arrows. Default behavior: With indentations ✗ With arrows ✔ After setIndentation(0) : Without indentations ✔ Without arrows ✗ Desired behavior: Without indentations ✔ With arrows ✔ So how can I achieve the result shown in the third example? Is there any standard way of

(Qt) Read access error when attempting to use any function from another widget class on my MainWindow

孤者浪人 提交于 2020-01-06 08:49:11
问题 I'd like to access some functions of a dialog-type widget from my mainwindow.cpp . I've created a simple function in the widget class that returns an int, which looks like this: dialog.h: public: int getRowCountData(); dialog.cpp: int Dialog::getRowCountData() { return ui->tableWidget->rowCount(); } Usage: my mainWindow.h: private: Dialog *dialog; my mainwindow.cpp: dialog = new Dialog; int count = dialog->getRowCountData(); <<<<<--------------this throws a read access error! code: 0xc0000005

QT High DPI Support on Windows

天大地大妈咪最大 提交于 2019-12-22 07:07:15
问题 According to documentation here http://doc.qt.io/qt-5/highdpi.html QT 5.4+ introduces high DPI support. However, either I’m missing something fundamental or the current support is still in very early stages. I’m writing a brand new application so I have a chance to do it right from the ground up. I understand that I would have to use layouts instead of fixed positioning etc, but there always going to be cases in which I would have to specify, for example a minimum/maximum size of a control. I