QSslSocket: cannot resolve SSLV2_client_method - qt

I have created a sslclient and sslserver using QSslSocket in Qt 5.4.1 in debian wheezy. When I run the program they dont work at all. After debuging my code I saw when it try to create a new object from QSslSocket it return this error (cannot resolve SSLV2_client_method) in constractor.
this is block of my code:
SSlClient::SSlClient(QObject *parent) : QObject(parent)
{
client = new QSslSocket(this);
client->setProtocol(QSsl::SslV3);
connect(client, SIGNAL(encrypted()), this, SLOT(startTransfer()));
connect(client, SIGNAL(encryptedBytesWritten(qint64)), this, SLOT(byteWritten()));
}

The problem has solved by compiling openssl as shared library.

Related

Qt6.2 network connection in the same LAN failed

I'm trying to write an app with Qt 6.2.4, and now I'm writing the internet-related part.Then something confused me.
I turned on Mobile Hotspot ,and my teammate and I both connected to it. After I started the server, we opened the client widget, only to find that the connection failed.Below are the code related to it.
server (Acctually it's provided by other person.To say frankly, I'm not familar with Qt's server)
NetworkServer::NetworkServer(QObject* parent)
: QTcpServer(parent)
, disconnMapper(new QSignalMapper(this))
, recvMapper(new QSignalMapper(this)) {
connect(this, &QTcpServer::newConnection, this, &NetworkServer::newconnection);
connect(this->disconnMapper, &QSignalMapper::mappedObject, this, &NetworkServer::disconnect);
connect(this->recvMapper, &QSignalMapper::mappedObject, this, &NetworkServer::receiveData);
this->listen(QHostAddress::Any, 2000);
}
client
mul_initwidget::mul_initwidget(QWidget *parent) :
QWidget(parent),
isConnected(false),
ui(new Ui::mul_initwidget),
username("user1")
{
ui->setupUi(this);
this->socket = new NetworkSocket(new QTcpSocket(), this);
qDebug()<<"mul_init create socket at" << (void*)&socket;
connect(socket, &NetworkSocket::receive, this, &mul_initwidget::receive);
//connect(socket->base(), &QAbstractSocket::disconnected, [=]() {
// QMessageBox::critical(this, tr("Connection lost"), tr("Connection to server has closed"));
//});
connect(socket->base(), SIGNAL(connected()), this, SLOT(setConnected()));
connect(socket->base(), SIGNAL(errorOccurred(QAbstractSocket::SocketError)), this, SLOT(setDisconnected(QAbstractSocket::SocketError)));
ui->label_2->hide();
socket->hello(IP,PORT);
if(isConnected)
ui->label->setText("Welcome, "+username);
else
ui->label->setText("Unconnected.");
}
Please comment if u think it's not enough to find out what's wrong, and I will add more code if I can.

undefined reference to `_imp___ZN15QSerialPortInfo14availablePortsEv'

I am working on simple app on windows to scan the serial port.
Error:
undefined reference to `_imp___ZN15QSerialPortInfo14availablePortsEv'
My Code:
foreach(const QSerialPortInfo &info, QSerialPortInfo::availablePorts()) {
// do something
}
What does the error mean and how to fix it.
i only needed to add QT += serialport in my project (appname.pro) file.

Error while connecting lambda function to QProcess::error

In following code I want to connect lambda function to QProcess::error signal:
void Updater::start() {
QProcess process;
QObject::connect(&process, &QProcess::error, [=] (QProcess::ProcessError error) {
qWarning() << "error " << error;
});
process.start("MyProgram");
process.waitForFinished();
}
But I get strange error:
error: no matching function for call to 'Updater::connect(QProcess*
[unresolved overloaded function type],
Updater::start()::)' });
What I do wrong here? The code executes inside method of class derived from QObject. The project configured to work with c++11.
I use Qt 5.3.1 on Linux x32 with gcc 4.9.2
Problem is that the QProcess has another error() method, so compiler just doesn't know which method use. If you want to deal with overloaded methods, you should use next:
QProcess process;
connect(&process, static_cast<void (QProcess::*)(QProcess::ProcessError)>
(&QProcess::error), [=](QProcess::ProcessError pError) {
qWarning() << "error " << pError;
});
process.start("MyProgram");
process.waitForFinished();
Yes, it looks ugly, but there is no another way (only old syntax?).
This special line tells compiler that you want to use void QProcess::error(QProcess::ProcessError error), so now there is no any ambiguity
More information you can find here.
For those who are using Qt 5.6 or later, the QProcess::error signal is deprecated. You can use the QProcess::errorOccurred signal instead to avoid the naming ambiguity and complicated casting.
QProcess process;
connect(&process, &QProcess::errorOccurred, [=](QProcess::ProcessError error) {
qWarning() << error;
});
process.start("MyProgram");
process.waitForFinished();

How to start video-suite in MeeGo / Nokia N9 from Qt code?

I am having problems with launching Nokia's own video player from my application that I just don't seem to be able to solve.
My first attempt included calling
Qt.openUrlExternally(url)
from QML and that seemed to do the trick just fine, except that it opened the browser every time and used it instead of the video-suite (native player).
Next I tried cuteTube -approach where I start new process like this:
QStringList args;
args << url;
QProcess *player = new QProcess();
connect(player, SIGNAL(finished(int, QProcess::ExitStatus)), player, SLOT(deleteLater()));
player->start("/usr/bin/video-suite", args);
That worked, except that it required video-suite to be closed upon calling player->start, otherwise it did nothing.
My third attempt involved starting the video-suite via QDBus, but that didn't work any better:
QList<QVariant> args;
QStringList urls;
urls << url;
args.append(urls);
QDBusMessage message = QDBusMessage::createMethodCall(
"com.nokia.VideoSuite",
"/",
"com.nokia.maemo.meegotouch.VideoSuiteInterface",
"play");
message.setArguments(args);
message.setAutoStartService(true);
QDBusConnection bus = QDBusConnection::sessionBus();
if (bus.isConnected()) {
bus.send(message);
} else {
qDebug() << "Error, QDBus is not connected";
}
The problem with this is that it requires video-suite to be up and running - autoStartService parameter didn't help either. If video-suite isn't running already, the call opens it just fine but, alas, no video starts to play.
Eventually I tried using also VideoSuiteInterface, but even having the program compile with it seemed to be difficult. When I eventually managed to compile and link all relevant libraries, the results didn't differ from option 3 above.
So, is there a way to use either VideoSuiteInterface directly or via DBus so that it would start video playback regardless of the current state of the application?
The solution was actually simpler than I really thought initially; the VideoSuiteInterface -approach worked after all. All it took was to use it properly. Here are the full sources should anyone want to try it themselves.
player.h:
#ifndef PLAYER_H
#define PLAYER_H
#include <QObject>
#include <maemo-meegotouch-interfaces/videosuiteinterface.h>
class Player : public QObject {
Q_OBJECT
private:
VideoSuiteInterface* videosuite;
public:
Player(QObject *parent = 0);
Q_INVOKABLE void play(QString url);
};
#endif // PLAYER_H
player.cpp:
#include "player.h"
#include <QObject>
#include <QStringList>
#include <QtDeclarative>
Player::Player(QObject *parent) : QObject(parent) {}
void Player::play(QString url) {
QList<QVariant> args;
QStringList urls;
urls << url;
args.append(urls);
videosuite = new VideoSuiteInterface();
videosuite->play(urls);
}
In addition you may want to connect some signals to make the UI more responsive, but basically that should do the trick.
Finally, you need to remember to add following to your .pro file and you are good to go:
CONFIG += videosuiteinterface-maemo-meegotouch

Nokia Qt: How to Play video from Phone Memory?

Can anyone tell me how to play video from phone memory??
EDITED :i have use this code for video Playing...
include "playvideo.h"
include "ui_playvideo.h"
include QFileDialog
include phonon/backendcapabilities.h
include phonon/videoplayer
include "mainwindow.h"
PlayVideo::PlayVideo(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::PlayVideo)
{
ui->setupUi(this);
videoPlay();
}
void PlayVideo::videoPlay()
{
QString fileName = QFileDialog::getOpenFileName(this, tr("Open Movie"), QDir::homePath());
Phonon::VideoPlayer *player = new Phonon::VideoPlayer(Phonon::VideoCategory,ui->graphicsView );
connect(player, SIGNAL(finished()), player, SLOT(deleteLater()));
player->play(fileName);
}
but it gives me error:
undefined reference to -> Phonon::VideoPlayer(Phonon::VideoCategory,QWidget*)
undefined reference to -> Phonon::VideoPlayer(Phonon::Mediasource const&)
Any idea?
Thanks..
Use either Phonon or QtMultimediaKit APIs.
For Phonon, there is a demo application in the Qt source tree (demos/qmediaplayer).
QtMultimediaKit is part of the QtMobility project, so in order to use it you require both Qt and QtMobility to be installed (in your SDK, and on the target device). There is a demo application in the QtMobility source tree (demos/mediaplayer).

Resources