19 Eylül 2019 Perşembe

QSerialPort Sınıfı

Giriş
Şu satırı dahil ederiz.
#include <QSerialPort>
Constructor
Şöyle yaparız.
QSerialPort port("COM1");
readyRead metodu
Şöyle yaparız.
port.setBaudRate(QSerialPort::Baud4800);
port.setDataBits(QSerialPort::Data8);
port.setStopBits(QSerialPort::OneStop);
port.setParity(QSerialPort::NoParity);
port.setFlowControl(QSerialPort::NoFlowControl);

QObject::connect(&port, &QSerialPort::readyRead,[&port](){
  qDebug() << port.readAll();
});

QObject::connect(&port, &QSerialPort::bytesWritten,[](qint64 bytes){
  qDebug() << bytes;
});

QObject::connect(&port, &QSerialPort::errorOccurred,
                     [](QSerialPort::SerialPortError error){
  qDebug() << error;
});

if (port.open(QSerialPort::ReadWrite)) {
  qDebug() << port.write("Test");
}

12 Eylül 2019 Perşembe

QApplication Sınıfı

Giriş
Şu satırı dahil ederiz.
#include <QApplication>
Qt QApplication ile diğer sınıfları bağlamak için kod üretir. Açıklaması şöyle
Qt preprocess your code and build the real c++ code before compiling, its at this moment QApplication wrap all Q object in the main.cpp file and build the rest of the code from it.
Açıklaması şöyle.
"It handles widget specific initialization, finalization."
constructor
Şöyle yaparız.
#include <QApplication>
#include <QPushButton>

int main(int argc, char **argv)
{
 QApplication app (argc, argv);

 QPushButton button ("Hello world !");
 button.show();

 return app.exec();
}
exec metodu
Örnek
Şöyle yaparız
#include "notepad.h"
#include <QApplication>

int main(int argc, char *argv[])
{
  QApplication a(argc, argv);
  Notepad w;
  w.show();

  return a.exec();
}
topLevelWidgets metodu
Şöyle yaparız.
QWidgetList list = QApplication::topLevelWidgets();

QPushButton Sınıfı

Giriş
Şu satırı dahil ederiz
#include <QPushButton>
show metodu
Şöyle yaparız.
QPushButton button ("Hello world !");
button.show();

10 Eylül 2019 Salı

QTcpSocket Sınıfı

Constructor
Şöyle yaparız
QTcpSocket socket;
connectToHost metodu
Şöyle yaparız
socket.connectToHost("198.168.101.230", 4400);
waitForConnected metodu
Örnek
Şöyle yaparız
if(socket.waitForConnected())
{
    qDebug() << "Connected";
    ...
}
else
{
    qDebug() << "Not Connected";
}
Örnek
Şöyle yaparız.
if (!socket->waitForConnected(connectionTimeout))
{
  ...
}
write metodu
Şöyle yaparız
socket.write("HELLO SERVER");

9 Eylül 2019 Pazartesi

QUrl Sınıfı

Constructor
Örnek
Şöyle yaparız.
QUrl url("http://www.icab.org.bd/icabweb/webGeneralContent/view/391829");
Örnek
Şöyle yaparız.
QUrl url ("file:///home/A/B/");
host metodu
Şöyle yaparız.

QUrl url = ...;
if (url.host() == "...") {
  ...
}
resolve metodu
Şöyle yaparız. Çıktı olarak "/home/other/file.pdf" alırız
QUrl oBase("file:///home/A/B/");
QString resolvedFile = oBase.resolved(QUrl("../../other/file.pdf")).toString();
scheme metodu
Şöyle yaparız.

QUrl url = ...;
if (url.scheme() == "...") {
  ...
}


11 Mart 2019 Pazartesi

qdbus komutu

--system seçeneği
Örnek
Şöyle yaparız.
$ qdbus --system org.freedesktop.NetworkManager 
  /org/freedesktop/NetworkManager/Devices/14 org.freedesktop.NetworkManager.Device.Driver
ath9k