qt4

QAbstractSocket::UnknownSocketError

拥有回忆 提交于 2019-12-20 03:37:06
问题 What could be cause of QAbstractSocket::UnknownSocketError when using QTcpSocket ? CODE I'm getting this error code with the following code: this->connect(socket, SIGNAL(socketError(QAbstractSocket::SocketError)), SLOT(handleSocketError(QAbstractSocket::SocketError))); ... void MyClass::handleSocketError(QAbstractSocket::SocketError error) { qDebug() << error; } MORE INFO The QTcpSocket is trying to connect to some remote host. And it fails with mentioned error code. 回答1: If you read the code

Qt jpeg can't work on my friend's PC

故事扮演 提交于 2019-12-20 02:52:34
问题 I am finishing a Qt app, but I encounted a problem. Here is it: I use this code to load image into a QGraphicsScene: QFile file(fileName); if(file.open(QFile::ReadOnly)){ QByteArray data=file.readAll (); pixmapItem.loadFromData (data,"jpeg"); } It works on my computer, but when I give this app to my friend, he just can't show this image. I Googled and searched Stack Overflow about this issue, which sounds like I need jpeg plugins. So, I do this: I copy qjpeg4.dll from C:\QtSDK\QtCreator\bin

How to end line with QTextEdit

冷暖自知 提交于 2019-12-20 01:45:27
问题 I'm trying to create QTextEdit with some text, and in this text I have end of line characters ( \n ), but it is not accepted in QTextEdit object (whole text is displayed without any breaks). Any reason why? 回答1: If you're using Qt 4.3 or later, then you can use setPlainText(const QString &text) You can turn off rich text editing with setAcceptRichText(bool accept) (Qt 4.1 or later) 回答2: Per the docs, if you setTextFormat(PlainText) you should get what you want -- quoting with added emphasis:

How to pass a QString to a Qt slot from a QMenu via QSignalMapper or otherwise

独自空忆成欢 提交于 2019-12-19 18:27:01
问题 I have a QMenu with many submenus. These are dynamically created i.e. the names menus come from a db and created in a loop. Now i wanted to fire the same slot triggered() or similar when a menu is clicked, but i needed the QString menu name to be passed to slot so i could perform menu specific actions. I have tried this i.e. passing a QAction * to the triggered event and used setData but i am getting the run time error. object::connect: No such signal QAction::triggered(QAction *) for(int j=0

Hide cursor in fullscreen mode using Qt 4.8?

心已入冬 提交于 2019-12-19 17:30:19
问题 I'm in a ArchLinux with OpenBox and I want to hide the cursor on fullscreen inside a Qt 4.8 application. I am aware about some other question about it but no one works every time: sometimes the cursor is hiding, sometimes not. I didn't managed to understand exactly when the problem occurs but I think that maybe is it related with the screensaver because if I test my application just after the computer is restarted the mouse cursor is no visible (and it is what I want) but if I test this

Hide cursor in fullscreen mode using Qt 4.8?

孤街浪徒 提交于 2019-12-19 17:29:50
问题 I'm in a ArchLinux with OpenBox and I want to hide the cursor on fullscreen inside a Qt 4.8 application. I am aware about some other question about it but no one works every time: sometimes the cursor is hiding, sometimes not. I didn't managed to understand exactly when the problem occurs but I think that maybe is it related with the screensaver because if I test my application just after the computer is restarted the mouse cursor is no visible (and it is what I want) but if I test this

Why does Qt use a signed integer type for its container classes?

半城伤御伤魂 提交于 2019-12-19 13:56:49
问题 The question is clear. I wonder why they even thought this would be handy, as clearly negative indeces are unusable in the containers that would be used with them (see for example QList's docs). I thought they wanted to allow that for some crazy form of indexing, but it seems unsupported? It also generates a ton of (correct) compiler warnings about casting to and comparing of signed/unsigned types (on MSVC). It just seems incompatible with the STL by design for some reason... 回答1: Because,

Qt4: Read Default mimeData from QAbstractTableModel

梦想的初衷 提交于 2019-12-19 10:25:33
问题 By default, the QAbstractTableModel class has a mimeData() function that returns a QMimeData object which has it's data set as an encoded QModelIndexList (see here). I would like to unpack this data in an overloaded dropMimeData() function, but can't figure out how to convert this QMimeData back into a QModelIndexList. I tried the obvious: bool myTableModel::dropMimeData(const QMimeData * mimeData, Qt::DropAction action, int row, int column, const QModelIndex & parent) { QStringList formats =

How to get decimal value of a unicode character in c++

别说谁变了你拦得住时间么 提交于 2019-12-19 10:23:12
问题 For one of my opensource projects, i need to compute the decimal equivalent of a given unicode character. For example if tamil character L'அ' is given, the output should be 2949 . I am using c++ in Qt environment. I googled and could not find a solution for this. Please help if you know a solution for this. 回答1: Use the unicode() method of the QChar object (which you can get e.g. with the at method of a QString , if a QString is what you have to start with). 回答2: cout << (int)c that's it 回答3:

Qt: is there a way to send a signal when a QProcess writes a line to stdout

橙三吉。 提交于 2019-12-19 08:59:45
问题 I've found similar questions but never the exact answer. I have Qt program that starts a QProcess and writes the output to a QTextEdit box, so far so good. But it only does so when the program has ended. if possible I'd like the programs stdout to be printed in real-ish time. In an ideal world there would be some sort of signal that QProcess emits when there is a line ready to read, if its not possible with QProcess is it possible at all? Also Ideally you could still use the rest of the