qt4.7

How to implement delegate in QHeaderView

痞子三分冷 提交于 2019-12-12 04:45:55
问题 I have created one table by using QTableview and QAbstractTableModel . i have added some vertical header by using QHeaderView . In one of the header cell i want to use delegate .. I am using the delegate but it does not have any impact .. Is anywhere i am doing wrong ? 回答1: Had this issue myself. The answer from the Qt documentation is simple and annoying: Note: Each header renders the data for each section itself, and does not rely on a delegate. As a result, calling a header's

Custom sorting method of QTableView?

落爺英雄遲暮 提交于 2019-12-11 09:28:48
问题 How can I setup custom sorting method for a QTableView , or for the model ? (Which function should I re-implement) The default sorting algorithm are for strings , I want a number sorting method for some specific column. Thanks. 回答1: You should use QSortFilterProxyModel. You should reimplement lessThan method. Then you have to set sourceModel for your proxy model, and set your proxy model as model for your view class MyProxyModel: public QSortFilterProxyModel { protected: bool lessThan ( const

QFlags Enum Type Conversion fails all of a sudden

牧云@^-^@ 提交于 2019-12-10 14:16:36
问题 I've had this code running for quite a while in a library: MyClass::MyClass() : QDialog() { // (...) setWindowFlags( Qt::CustomizeWindowHint | Qt::WindowTitleHint ); // (...) } Then, after changing various parts of the library, I get this message all of a sudden: error C2664: 'QWidget::setWindowFlags': cannot convert parameter 1 from 'int' to 'Qt::WindowFlags' Apparently it doesn't find the | operator overload provided by the QFlags class so that the result of | returns an int rather than a

How to add a tick mark to a slider if it cannot inherit QSlider

独自空忆成欢 提交于 2019-12-09 01:21:46
问题 I have a Qt dialog and there is a slider in it, when the dialog is initialized the slider will be set a value. In order to remind the user what is the default value, I want to add a mark to the slider, just draw a line or a triangle above the handle. Here, the slider should be of QSlider type, that means I can't implement a customized control derived from QSlider. Is there any way to realize it ? 回答1: I'm not clear why you can't derive a control from QSlider . You can still treat it like a

Cannot find Qt files when compiling

空扰寡人 提交于 2019-12-08 07:20:45
问题 I've a QT project that was initially designed both for UI as well as creating a server for the network. However, now I only need the network part of it to integrate with another UI implementation. I stripped out the files and main function and compile the project as a library. All goes well. However, when I try to include a header file from this project into another project, I get compile time errors like these (for the project that calls header files from QT project): fatal error C1083:

Rebuilding again and again to view the imported QML file changes

不羁岁月 提交于 2019-12-08 04:13:18
I have imported a qml file say A in other qml say B. Whenever I make some changes in A , it doesn't reflect in the Application. I have to again clean and rebuild to view the changes i made, which is very time-consuming. Is there an easier and efficient way of doing this, so time could be saved . Or another way of saying this is : qrc files are not added to Makefile dependencies in debug_and_release mode example A.qml Rectangle { id:xyz Button { id: ButtonA } } B.qml Rectangle{ A { id:abc } } I am using qt 4, qtquick 1.0. You can make two independent qrc files, one for debug which is only

qt creator debug slow

▼魔方 西西 提交于 2019-12-07 03:58:37
问题 I'm running Qt Creator 2.3.0, based on Qt 4.7.4, on Windows 7 64-bit. When I run the app from Qt Creator (ctrl+r), everything works great. However, when I debug (F5), executing each line takes forever - as in sometimes 2 minutes to execute a single line of code. I noticed in the Debugger Log window this line: Debugger: C:\Program Files (x86)\Debugging Tools For Windows (x86)\cdb.exe. I thought since I'm running Windows 7 x64, I should be using the 64-bit debugger. So, I downloaded and

QNetworkRequest with ssl local certificate

好久不见. 提交于 2019-12-04 15:46:34
I need to exchange data with server which requires local certificate (.crt file). I try this: loginRequest = QNetworkRequest(QUrl("https://somesite.com/login")); QSslConfiguration sslConf = loginRequest.sslConfiguration(); QList<QSslCertificate> certs = QSslCertificate::fromPath(Preferences::certificatePath()); qDebug() << certs.first().issuerInfo(QSslCertificate::Organization); // prints name sslConf.setLocalCertificate(certs.first()); qDebug() << "is valid " << sslConf.localCertificate().isValid(); // true qDebug() << "is null " << sslConf.localCertificate().isNull(); // false qDebug() <<

Setting default make options for Qt Creator?

痞子三分冷 提交于 2019-12-03 06:38:56
问题 How can i override default make parameters , which is: make -w Each time i create a project , i had to modify project settings , adding -j4 to make parameters. Can i set make -w -j4 by default ? EDIT The best way to do this is setting MAKEFLAGS environment variable , i'm picking the only answer as the best only to shut this thread down. To set this for UNIX, modify the *.desktop file of Qt Creator , prefix the line entitled Exec= with env MAKEFLAGS=-j4 , but be aware that you won't be able to

QObject based class has a queued connection to itself

北城以北 提交于 2019-12-01 18:40:21
问题 I was digging into some source code I am working on. I found a peculiar statement that someone had coded. The source code is a GUI application with a QML GUI and uses QT 4.7.x. The snippet below belongs to core application logic. // connect signal-slots for decoupling QObject::connect (this, SIGNAL(setCurrentTaskSignal(int)), this, SLOT(SetCurrentTaskSlot(int)), Qt::QueuedConnection); It's strange that the object connects to itself via a queued connection which essentially means that the