Showing posts with label Qt-SDK. Show all posts
Showing posts with label Qt-SDK. Show all posts

2015-10-12

Qt: Dynamic Copy File in the Thread example, requires Wraparound class


  • Wraparound class


ThreadCopyFile::ThreadCopyFile(QObject *parent) : QObject(parent)
{
    qDebug() << this << "Created";

    this->v_thread = new QThread();
    this->v_copyFile = new CopyFile();
     

    connect(v_thread,SIGNAL(started()),v_copyFile,SLOT(Copy()));
    connect(v_copyFile,SIGNAL(done()),v_thread,SLOT(quit()));
    connect(v_thread,SIGNAL(finished()),this,SLOT(finished()));

    this->v_copyFile->moveToThread(this->v_thread);
    this->v_thread->start();

}

ThreadCopyFile::~ThreadCopyFile()
{
    delete this->v_thread;
    delete this->v_copyFile;
}

public slots:


void ThreadCopyFile::finished()
{
    qDebug() << this << "Finished";
    this->~ThreadCopyFile();
    qDebug() << this << "Destroyed";
}



  • Class for actual work


CopyFile::CopyFile(QObject *parent) : QObject(parent)
{
    qDebug() << this << "Created";


}

CopyFile::~CopyFile()
{
    qDebug() << this << "Destroyed";
}


signals:


    void done();

public slots:

void CopyFile::Copy(void)
{

    QString src = "/media/data/torrent/linuxmint-17.2-mate-32bit.iso";
    QString dst = "/tmp/linuxmint-17.2-mate-32bit.iso";

    if(QFile::exists(dst))
    {

        qDebug() << "file exists";

        if(QFile::remove(dst))
        {
            qDebug() << "Files removed";
        }
        else
        {
            qDebug() << "Files  fail to remove";
        }
    }

    qDebug() << "Copy File started";

    if(QFile::copy(src,dst))
    {
        qDebug() << "Copy File finished";
    }
    else
    {
        qDebug() << "Copy File fail";
    }

    emit done();
}



UI runs on other thread, everything work nicely :)


2015-09-19

QT UI for youtube-dl








Downloads

There is some obvious things should be fix'ed, but is't usable right now... and more convenient then terminal.

 



2015-01-25

Digital background color


I think in the old days, white screen with black letters was design to make an impression of sheet of paper. Now it still exists.
On Smart Phones and Tablets it's changing cause less white light means longer battery life. On the Desktop not a lot of normal people care. Unless that’s your style and You want to be unique.

My digital background's turning black not only cause its environment friendly, but the main reason is how it effects my eyes. I noticed that dark background while programming are less intense for my eyes.

It worth mention that, the room where you work also sloud be similre lighting as your computer screen. You also shloud look at the monitor a fiew degrees down and don't forget blink. This way your eyes will be less dray.  About blinking it's easier to say than done! :)

If you do tee or coffee break, to give your eyes a break you should look throw the window far far away.

I do not ware glasses!  At least Yet!

I have one weaker eye then the other. My vision changing during the week. If I would do eye test , ware you cover one eye and then have to see and say letters or animal names watching form the distance, on a Friday after intensive work week I most likely failed, but on Monday after a weekend in the village away and away from PC, I most likely pass the test.



So it's great that Qt-Creator can have a dark skin!

https://github.com/alexpana/qt-creator-wombat-theme





And "Sublime text" it's great by default. If You did not try yet, It's a great editor, definitely should try out!

http://www.sublimetext.com/



Keep your eyes healthy :) and have fun programming!



2014-10-04

Blank project error after Qt installation

 
cannot find -lGL 
error: collect2: error: ld returned 1 exit status 


Solution:

$ sudo apt-get install libgl1-mesa-dev



2013-11-23

Using sqlite in Qt Application



 I got this error, every time a reopen or open a new database file:
 
QSqlDatabasePrivate::removeDatabase: connection 'qt_sql_default_connection' is still in use, all queries will cease to work.
QSqlDatabasePrivate::addDatabase: duplicate connection name 'qt_sql_default_connection', old connection removed.

Sometimes I get lazy and ask google first. This time google didn't tell me.
 A few noobs like me had the same issue. There was discussion about that, but they actually was digging to deep!

The answer is very simple!

Load driver only once:

QSqlDatabase::addDatabase("QSQLITE");

And then, the database file you can close and open multiple times:

db.setDatabaseName("myDatabase.sqlite");

if (db.open())
{
qDebug() << db.lastError();

}
else
{
qDebug() << db.tables();
}


db.close();




2013-10-05

Scheduled shutdown user friendly way with qZleep on Linux Mint

A simple tool scheduled shutdown in 24 hours. Perhaps you want to let finished same job for same time...
Or you like watch TV show in the bed and your brain

shutdown unpredictably... 
It is very unpleasant to wake up at night and then turn off everything...





Download Package
For Linux Mint and Ubuntu

Mirror: qzleep_0.1.0-4_amd64.deb
Mirror: qzleep_0.1.0-4_i386.deb


 qzleep_0.1.0-4_i386.deb
 qzleep_0.1.0-4_amd64.deb

tested on
 Mint 14 MATE
 Mint 15 KDE
 Ubuntu 12.04

Sources:

https://github.com/elektronas/qZleep.git



2013-04-16

Favorite Linux applications


Video Player: mplayer
               without skin 

Media Center: xbmc  (PC video on TV)
            This is the reason for baying HTPC not a player with embedded software inside...

Music Player: deadbeef
         Preferred  lossless audio (flac)

Mail Client: gnome evolution mail
          on Debian works better then on Mint or Ubuntu

Internet Browser: Firefox

Text Editor: Medit
          For those how like notepad++ on Windows, I think, Medit is the best choice on Linux

Torrent Client: Deluge

Calculator: Galculator
         for hex to bin & dec to hex ...


Disk & Partition Tools: Gnome disk utility
        Debian squeeze version only (bad update for Ubuntu or Mint)


Home server: lighttpd,proftpd


Communication: skype 2.2.0.35 beta
        I gonna use skype until this version works (updates not welcome!)
        Now tying to find free & so-so working voip client, no success jet.

USB Boot disk creator: unetboot

Development: Qt-SDK, Codelite-IDE