Project file (.pro) Add the following line to your .pro file
QT += sql Header #include <QtSql/QSqlDatabase> #include <QtSql/QSqlError> class DatabaseManager { public: DatabaseManager(); ~DatabaseManager(); public: bool openDB(); bool deleteDB(); QSqlError lastError(); private: QSqlDatabase db; }; Source bool DatabaseManager::openDB() { // Find QSLite driver db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName("database_name_here"); // Open databasee return db.open(); } QSqlError DatabaseManager::lastError() { // If opening database has failed user can ask // error description by QSqlError::text() return db.lastError(); } bool DatabaseManager::deleteDB() { // Close database db.close(); return QFile::remove("database_name_here"); } Execute a query QSqlQuery query; // Create a new table query.exec("CREATE TABLE filelist(fullpath VARCHAR PRIMARY KEY, timestamp VARCHAR)"); // Prepare file Information to insert QFileInfo currentFile = ...; QString filepath = currentFile.absoluteFilePath(); QString timestamp = currentFile.lastModified().date().toString("yyyy-MM"); // Insert a record to the database query.exec("INSERT INTO filelist VALUES('" + filepath + "', '" + timestamp + "')"); // You can also insert a record as following query.prepare("INSERT INTO filelist VALUES(?, ?)"); query.addBindValue(filepath); query.addBindValue(timestamp); query.exec(); query.exec("DROP TABLE filelist");
If you are or want to be an open-source developer, you must try GitHub. It is a new hosted Git repository service that’s being called a “social network” for programmers. It is basically a distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
Setup SSH key Generate SSH Key If you have created your account at GitHub and now you want to work with it from your terminal.
In this tutorial I will describe the required steps for setting up a pseudo-distributed, single-node Hadoop cluster backed by the Hadoop Distributed File System, running on Ubuntu Linux.
This tutorial has been tested with the following software versions:
Ubuntu 13.04
Apache Hadoop 1.1.2 (Released on February 15th, 2013)
Prerequisites Oracle Java 7 Hadoop requires a working Java 1.5+ (aka Java 5) installation. In this tutorial, I will describe the installation of Java 1.7.0 Update 21.
I have been using Sun Pinyin for quite a long time, but once I used Google Pinyin, I found it great.
So, let me tell you how to install Google Pinyin in ubuntu.
First, you should add a PPA source:
sudo add-apt-repository ppa:fcitx-team/nightly sudo apt-get update Then, you should install Fcitx、Fcitx-googlepinyin:
sudo apt-get install fcitx fcitx-googlepinyin If you want to use “Cloud”, you should install fcitx-module-cloudpinyin:
sudo apt-get install fcitx-module-cloudpinyin
Why would I need to change the layout? Every time I upgrade the desktop for a new Ubuntu version it defaults it to a 2×2 layout.
I don’t have a monitor on top of another so why would I use vertical workspaces? It maybe has advantages for some else workflow. Not mine. I’m used to horizontal multiple screens.
How can I define a new workspace layout? You can change several parameters with the Compiz Config Settings Manager. I found that some friends didn’t have it installed. So, just install it first.
Excel stores a date internally as a number of days since January 1, 1900.
For example: “June 9th, 2011 10:30 AM” would be stored as “40703.4375”.
40703 is the number of full days since 01/01/1900 and 0.4375 represents the time (10.5/24 = 0.4375).
When you process dates read from an Excel spreadsheet (e.g. using PHPExcel) you often want to convert them into a UNIX timestamp i.e. a number of seconds elapsed since midnight of January 1, 1970 UTC.
Welcome to the first windows tutorial. In this tutorial, I’ll give you the basic information on how to code in windows and we’ll go over a few important details first.
The basic windows program has two important functions inside. The first one is the event handler(I’ll talk about this one later on) and the second one is the main function(WinMain from now on). WinMain is similar to DOS’ main function, in fact, WinMain is called from the DOS main function but in windows, we don’t have access to the DOS main; everything is covered up by windows. Windows introduces us to messages. A message could be easily described as a pile of data that gets sent to the event handler which then tells the window what to do. A message’s name is prefixed with WM(stands for Windows Message as you might have guessed?). There are a whole lot of messages that a window can handle, however, we’ll only need a few of them. You can use these messages in many ways. For example, the message WM_CREATE, can be used for initialization purposes, it gets sent to the window when it’s created, and WM_PAINT is used when you want to draw something on the screen, and so on, you get the image. Most of the messages get sent to the window automatically, as example when you move your mouse around you send a message to windows, and any other things such as that send messages to windows. You can also send a message to your window yourself, but you’ll probably never need to.
To access CodeIgniter’s native resources within your library use the get_instance() function. This function returns the CodeIgniter super object.
Normally from within your controller functions, you will call any of the available CodeIgniter functions using the $this construct:
$this->load->helper('url'); $this->load->library('session'); $this, however, only works directly within your controllers, your models, or your views. If you would like to use CodeIgniter’s classes from within your own custom classes you can do so as follows: