天道酬勤,学无止境

qt

Is a configuration of clang QtC 4.7 checks per config file possible?

QtC 4.7 offers the inline CLANG code checks, as shown in the screenshots. I can configure those from options/C++. But I wonder if I can have a config file which I can commit (git) so everyone in the team is using the same checks. Is that possible (e.g. similar to Artistic style where I can use a file or the config in QtC)? The checks I mean: Configure in C++ options, can I do the same in a config file? --- Edit --- I could use the annotations like [[clang::fallthrough]] which silence the warning, but cause other issues like VS2017 "attribute not supported warnings" (we compile on 3 compilers).

2022-01-25 05:37:08    分类:问答    qt   clang   qt-creator

如何使用设置了 cellWidget 的 QTableWidget 单元格处理信号(How to work with signals from QTableWidget cell with cellWidget set)

问题 我有一个QTableWidget ,里面有一些列。 由于我的需要,我在一些列中设置了QComboBox并用必要的数据填充它们。 void settingsDialog::onAddFieldButtonClicked() { fieldsTable->setRowCount(++rowCount); combo = new QComboBox(); combo->addItem(QString("Choose from list...")); foreach( int height, heightsAvailable) combo->addItem(QString("%1").arg(height)); fieldsTable->setCellWidget(rowCount-1, 3, combo); // etc for other columns ... } 问题是如何从这些组合框中捕获信号,如果它们被改变了? 我想知道更改的小部件(组合框)的row和col以及设置的值。 我已经尝试了QTableWidget的 Qt 文档中提到的所有可用信号,但它们仅在单元格内部没有小部件时才有效。 有没有一种简单的 Qt 方式来获得我需要的东西? 回答1 您可以处理来自组合框本身的currentIndexChanged信号,而不是处理来自表的信号。 QComboBox* combo =

2022-01-25 05:31:27    分类:技术分享    qt   signals   qtablewidget

Qt QString cloning Segmentation Fault

I'm building my first Qt app using Qt Creator, and everything was going fine until I started getting a strange SIGSEGV from a line apparently harmless. This is the error: Program received signal SIGSEGV, Segmentation fault. 0x0804e2fe in QBasicAtomicInt::ref (this=0x0) at /usr/lib/qt/include/QtCore/qatomic_i386.h:120 By backtracing the exception on gdb, I found that a simple getter is passing a NULL pointer to the clone constructor when I return my attribute. Backtrace output: (gdb) backtrace #0 0x0804e2fe in QBasicAtomicInt::ref (this=0x0) at /usr/lib/qt/include/QtCore/qatomic_i386.h:120 #1

2022-01-25 03:54:39    分类:问答    c++   qt   pointers   qstring

如何摆脱 QDialog 中的调整大小句柄?(How can I get rid of the resize-handle in a QDialog?)

问题 我有以下课程: class SelectDateDialog(QDialog): startDate = date.today() endDate = date.today() def __init__(self, text, isInterval = False): QDialog.__init__(self) uic.loadUi("resources/SelectDate.ui", self) 现在,该对话框在 Mac OS X 10.5 上可以调整大小,但不应该如此。 它在右下角有调整大小的句柄。 我已经尝试过setSizeGripEnabled功能,它没有改变任何东西。 我怎样才能使它不可调整大小? 回答1 如果你想要一个不可调整大小的 QDialog dlg,那么设置 dlg.setWindowFlags(Qt::MSWindowsFixedSizeDialogHint); 回答2 我使用以下代码来修复QDialog的大小: layout()->setSizeConstraint( QLayout::SetFixedSize ) ; setSizeGripEnabled( false ) ; 第一行根据布局中包含的小部件的首选大小强制布局大小。 第二行删除了实际的抓地力。 要扭转这种情况,您可以在布局上设置默认约束并重新启用尺寸夹点。 回答3

2022-01-25 03:51:35    分类:技术分享    qt   pyqt

用pyqt5生成SVG文件(Generate a SVG file with pyqt5)

问题 我想使用 pyqt5 使用 Python 绘制一些简单的矢量图像。 到目前为止,我已经设法使用以下代码生成图像: import sys from PyQt5.QtCore import * from PyQt5.QtGui import * from PyQt5.QtWidgets import * class MyPainter(QImage): def __init__(self): super().__init__(400, 400, QImage.Format_RGB32) self.fill(Qt.black) painter = QPainter(self) painter.setPen(QPen(Qt.red, 8)) painter.drawRect(40, 40, 200, 100) if __name__ == "__main__": app = QApplication(sys.argv) w = MyPainter() w.save('test.png', 'PNG') 绘制以下图像: 我想做同样的事情,但渲染一个 SVG。 pyqt5.qtsvg 模块可以吗? 它将如何插入到上面的代码中? 我只是找不到任何例子。 回答1 我终于找到了解决方案: from PyQt5.QtCore import * from PyQt5.QtGui import *

2022-01-25 03:45:06    分类:技术分享    python   qt   svg   qt5   pyqt5

Static compile Qt 5.13.1 with -openssl-linked using MinGW (Windows 10)

Re: Static compilation. Qt 5.12.3 Good day Qt Forum suggested I create a new post as the linked one is 'quite old' This essentially serves as a confirmation of some 'bug', what the exact problem is I am not sure, but I can simply provide you with my compile script and the error. The purpose is to compile OpenSSL against Qt, which will allow me to compile a single all-in-one binary application I can ship. I was able to achieve this but had inconsistency issues, thus bringing me back to the recompilation side. The error compilation line repeating is shown below: ..\..\..\..\include

2022-01-25 02:53:49    分类:问答    c++   qt   ssl   openssl   qmake

How to work with signals from QTableWidget cell with cellWidget set

I've got a QTableWidget with some columns inside. Due to my needs I set QComboBox inside some columns and fill them with necessary data. void settingsDialog::onAddFieldButtonClicked() { fieldsTable->setRowCount(++rowCount); combo = new QComboBox(); combo->addItem(QString("Choose from list...")); foreach( int height, heightsAvailable) combo->addItem(QString("%1").arg(height)); fieldsTable->setCellWidget(rowCount-1, 3, combo); // etc for other columns ... } The question is how to catch signals from these combo boxes if they were changed? I want to know row and col of changed widget (combo box)

2022-01-25 02:49:18    分类:问答    qt   signals   qtablewidget

使用 QNetworkAccessManager 支持 https。 在运行时命中 SslErrors(Support for https using QNetworkAccessManager. Hitting SslErrors at runtime)

问题 我正在使用 QNetworkAccessManager 执行 https 获取操作。 我在运行时遇到 SSLErrors。 经过一段时间的研究,我能够在安装 OpenSSL 后运行我的程序。 我需要两个 dll:libeay32.dll 和 ssleay32.dll。 是说我不能在没有 OpenSSL 的情况下使用 QNetworkAccessManager 执行 https“get”操作吗? Qt 不支持使用 QNetworkAccessManager 的原生 https 支持。 谢谢,德科斯托。 回答1 必须将在以下网站上找到的以下 dll 安装到我的机器上:http://www.slproweb.com/products/Win32OpenSSL.html 加密受到国籍的严密保护。 所以,更多信息在: http://developer.qt.nokia.com/faq/answer/how_can_i_add_ssl_support_to_my_qt_application

2022-01-25 02:15:52    分类:技术分享    qt   https   network-programming   get   qnetworkaccessmanager

Change height and icon position of QToolBox tabs, using proxys

Ok, so I want to customize the height and the position of icons of the tabs from a QToolBox widget. I am not able to do it using stylesheet (I tried different options, but none worked, see question: Customizing QToolBox: tab height), so I decided to give it a try to using a proxy. I know there are the controlElements: CE_ToolBar CE_ToolBoxTabShape CE_ToolBoxTabLabel And so I can use them on the drawControl function to get what I want. void drawControl(ControlElement oCtrElement, const QStyleOption *poStyleOptionption, QPainter *poPainter, const QWidget *poWidget) const But I am not sure how to

2022-01-25 02:01:10    分类:问答    qt   proxy   toolbox