qt4

How to deep copy QMap and other Qt containers

天大地大妈咪最大 提交于 2019-12-10 03:54:46
问题 Generally speaking, what is the correct way to deep copy Qt containers? I'm not worried about deep copying the containers recursively, although addressing such would be helpful. 回答1: Despite what everyone will tell you - that you don't deep copy Qt containers - there are situations in which you simply need to perform an actual deep copy instead of just a shallow one. To do that, use detach() : container1 = container2; container1.detach(); 来源: https://stackoverflow.com/questions/16800206/how

How to trigger the edit mode of an item in a QTableView?

这一生的挚爱 提交于 2019-12-10 03:34:33
问题 I'm using QTableView and QStandardItemModel now. In the QTableView, if you double-click a cell, this cell will get into edit mode and you can edit its content. Now I have a problem, I want to trigger the edit mode of an item by code (by command), what should I do? I cannot find proper function or slot in QTableView or QStandardItemModel. Do I need to emit any signal to get into edit mode? And which signal I should catch if I want to know when the editing is finish (user press "Enter" or click

QCheckbox/QRadioButton line wrap Qt4.6.0

一世执手 提交于 2019-12-10 03:30:31
问题 I'm trying to have a multi-line checkbox/radiobutton with Qt using standard QCheckbox/QRadioButton. I didn't find the direct solution since QRadioButton{wrap:true;} has no effect. The only thing possible would be to access to the QRadioButton->label->setLineWrap(true) but I'd like to do that from the designer not having to rewrite a widget Any idea beside putting a QRadioButton and a QLabel next to each others? Thx, Boris. 回答1: That indeed is really annoying and cannot be solved without

How to remove focus from a QLineEdit when anyplace else on the window is clicked

半城伤御伤魂 提交于 2019-12-10 02:21:21
问题 I'm working on a custom Qt button that allows you to edit the text on the button if you double click it. When the button is double clicked, a QLineEdit appears where the text on the button is allowing the user to edit the text on the button. My requirement is that if the user clicks anywhere in the application window, the QLineEdit should disappear and cancel the edit operation. This works in some cases. Specifically, it works if I click on anything that is capable of text entry. Other

No syntax highlight for *.qss file in Qt Creator?

我怕爱的太早我们不能终老 提交于 2019-12-10 01:27:10
问题 It's wired that Qt Creator didn't have a syntax highlight for its own style file format , or did i missed some packages ? VER: Qt Creator 2.1.0 回答1: I could not find any evidence in Qt's documentation that .qss is an officially designated file extension. I'd say just change it to .css . 回答2: Go to Tools > Options > Environment > Mime types Find text/css and add *.qss to patterns. 来源: https://stackoverflow.com/questions/7624656/no-syntax-highlight-for-qss-file-in-qt-creator

How to pass click event to sibling underneath in Qt?

邮差的信 提交于 2019-12-10 00:58:48
问题 I have two overlapping widgets in a window child A and child B. Child A is above B and gets mouse events but sometimes the click should pass through and eventually hit child B. The ideal solution would have been to use event->ignore() but this passes the event to the parent widget, not siblings. The "pass all" solution setAttribute(Qt::WA_TransparentForMouseEvents); does not work either because child A needs to capture some events. How do I tell Qt "I do not want to handle this event, act

Qt QTableWidget's gray dotted border around a selected cell

Deadly 提交于 2019-12-10 00:56:49
问题 I'm wondering if anyone knows of, perhaps a flag to disable the gray dotted border that appears when you single click on a QTableWidget's cell. Thanks. 回答1: C++: tableWidget->setFocusPolicy(Qt::NoFocus); Python: tableWidget.setFocusPolicy(QtCore.Qt.NoFocus) Be aware that you will lose the ability to process keyboard events, but mouse events will work fine. 回答2: It seems like you want to remove the border when the cell get the focus. Try editing the Stylesheet as follows. QTableWidget {

Reading HTTP headers

拜拜、爱过 提交于 2019-12-10 00:28:23
问题 I am trying to connect my application with a web service and here ,a user suggested to send custom headers back to my application. I am using this code void Coonnec::serviceRequestFinished(QNetworkReply *reply) { QByteArray bytes = reply->readAll(); if (reply->error() != QNetworkReply::NoError) { qDebug() << "Reply error: " + reply->errorString(); } else { qDebug() << "Uploaded: " + QDateTime::currentDateTime().toString(); qDebug() << reply->rawHeaderList(); } reply->close(); bytes.clear();

dynamic memory in QList

穿精又带淫゛_ 提交于 2019-12-09 19:06:56
问题 I don't have much experience with QT and this problem came out today. QList<int> memList; const int large = 100000; getchar(); for (int i=0; i<large; i++) { memList.append(i); } cout << memList.size() << endl; getchar(); for (int i=0; i<large; i++) { memList.removeLast(); } cout << memList.size() << endl; getchar(); After first loop when I check memory usage it goes up as new elements are appended to the memList but after removing them within second loop the memory usage stays at the same

Linker error 'unresolved external symbol' : working with templates

◇◆丶佛笑我妖孽 提交于 2019-12-09 16:31:42
问题 I have a template based class [Allotter.h & Allotter.cpp]: template <typename allotType> class Allotter { public: Allotter(); quint32 getAllotment(allotType*); bool removeAllotment(quint32, int auto_destruct = 0); private: QVector<QPair<quint32, allotType*>> indexReg; int init_topIndex; }; and it's usage is shown as [ActiveListener.h & ActiveListener.cpp]: class ActiveListener: public QObject { Q_OBJECT public: ActiveListener(); private slots: void processConnections(); void readFromSocket