qt-signals

Connect: No such Slot QTreeView

时间秒杀一切 提交于 2019-12-11 13:33:56
问题 I have inherited a class MainTree from QTreeview maintree.cpp file void MainTree::LaunchTree() { //Tree launching connect(this, SIGNAL(customContextMenuRequested(const QPoint& )),this,SLOT(showCustomContextMenu(const QPoint&))); } void MainTree::showCustomContextMenu(const QPoint &pos) { //Add actions } But i get the following error QObject::connect: No such slot QTreeView::showCustomContextMenu(const QPoint&) I could not understand why, am i missing something ?? Definition of the class

For a NOTIFY signal on a property, what difference does it make if I give it a parameter?

时光怂恿深爱的人放手 提交于 2019-12-11 08:41:47
问题 Suppose I have a class that looks like this: class Something : QObject { Q_PROPERTY(int something READ getSomething NOTIFY somethingChanged) // ... signals: void somethingChanged(); } According to the documentation, declaring somethingChanged as void somethingChanged() and void somethingChanged(int) (note the parameter) are both valid. Why would I want to do it one way over the other? 回答1: Emitting the value allows you to use that value without having a reference to the object it is a

how to notify that the maxlength is overflowing

只谈情不闲聊 提交于 2019-12-11 07:53:26
问题 Is there a way to connect a signal before executing a default handler? I'm looking for a way to execute my function prior to QLineEdit::textChanged signal to execute notification about maximum length limit. GTK+ has connect_before(), connect() and connect_after(). Is there something similar in Qt? 回答1: You can use the keyPressEvent method to issue the custom signal. #include <QtWidgets> class LineEdit: public QLineEdit { Q_OBJECT public: using QLineEdit::QLineEdit; signals: void

inputRejected signal not found

余生颓废 提交于 2019-12-11 05:35:26
问题 ALL, connect(this, &QLineEdit::inputRejected, this, &this::my_handler); Qt 5.7.1 on Gentoo Linux error: 'inputRejected' is not a member of 'QLineEdit' Documentation doesn't give any restrictions on that signal. What is the problem? TIA! 回答1: inputRejected() has been recently introduced in Qt 5.12 so you'll have to update your version of Qt. [QTBUG-57448] Added inputRejected() signal for when a key press is not accepted by the QLineEdit. For instance, when an invalid key is pressed for a

Disconnect and later reconnect a Qt signal

感情迁移 提交于 2019-12-10 16:40:06
问题 Is there a way to disconnect a Qt signal only temporarily, but store a list of the objects connected to it, so the signal can later be reconnected to them? 回答1: http://qt-project.org/forums/viewthread/6820 This post discusses ways to keep track of the list of connections to a particular signal which could be used for reconnecting it after disconnect is called. 来源: https://stackoverflow.com/questions/14144415/disconnect-and-later-reconnect-a-qt-signal

Why a new signal for socket::readyRead() is executed, even when its earlier slot is still processing?

☆樱花仙子☆ 提交于 2019-12-10 13:24:31
问题 According to following post an emitted signal is served, only once the currently executing slot completes. Wait for a SLOT to finish the execution with Qt I have a client-server communication app based on ssl socket, which is single threaded. connect(socket, &QSslSocket::readyRead, [&]() { myObject.Read(); }); Client & server send each other some custom messages. Whenever a message is sent or received by either, they send ACK bytes (00). Most of the times, I notice that when the Read() is in

Qt Signal/Slots sending a complete structure

江枫思渺然 提交于 2019-12-08 21:17:13
问题 I am attempting to send a structure via signals/slots between two threads, my signals/slots are connected properly and I have been able to send QStrings containing parts of my data but now I need to send the whole thing and Structures seem most sensible. However when I try the signal is not sent/recieved. The problem seems to be only with sending/receiving the structure, the processing before and after I have tried many ways. I cannot use pointers such here or here as my data is generated too

QTableView disable sorting for some columns

随声附和 提交于 2019-12-08 12:35:18
问题 I am using QtableView(qt5.9) with 10 columns and want to disable sorting for 2nd and 3rd (only some) columns when the user clicks on the header of these columns. I use setsortingenabled flag to make my QtableView allow sorting Is there any signal which I should listen to on clicking of header and then call some appropraite method or deny sorting. 回答1: You can use the header signal sortIndicatorChanged to restore the current sort indicator. Example: connect(m_poTableView->header(),

pass value to slot with QNetWorkAccessManager

坚强是说给别人听的谎言 提交于 2019-12-08 11:29:47
问题 I'm trying to use QsignalMapper to pass my String to img_loaded function, on finished SIGNAL. But I can not get any result, please help. QString mystring = "value"; QNetworkAccessManager *m_netwManager = new QNetworkAccessManager(this); QUrl url("http://images.gs-cdn.net/static/albums/80_9299765.jpg"); QNetworkRequest request(url); connect(m_netwManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(img_loaded(QNetworkReply*))); void MainWindow::img_loaded(QNetworkReply *rep){ //Handle my

Is QProcess::finished emitted if the child process crashes?

半腔热情 提交于 2019-12-08 08:03:51
问题 The documentation says that the error() signal will be emitted if the child process crashes, but would finished() be emitted as well or is it only emitted when it exits successfully? 回答1: Yes. And it returns you status, as docs state: void QProcess::finished ( int exitCode, QProcess::ExitStatus exitStatus ) [signal] QProcess::NormalExit 0 The process exited normally. QProcess::CrashExit 1 The process crashed. 回答2: You can find out by testing it. Write a small program that does a NULL pointer