Roland Ihasz

QSqlDatabase connection testing tool

QSqlDatabase connection access

A simple command line tool to test connection between Qt client applications and a remote Mysql Server. The code includes Secure Sockets Layer (SSL) support to test secure connection. The QSqlDatabase class provides an interface for accessing a database through a connection. An instance of QSqlDatabase represents the connection. The connection provides access to the database via one of the supported database drivers (MySQL in our case), which are derived from QSqlDriver. Alternatively, we can subclass your own database driver from QSqlDriver. I’ll post an another article about how to write your own database driver in Qt for Unix, OSX and Windows platforms. It’s recommend to write your own database driver especially when you planning to deploy your application in different platforms. It’s simply because there could be surprises especially on client deploying your application that using one of the supported database drivers due to missing dependencies or environmental variables.

Software prerequisites:
Remote MySQL server version: 5.7 or above
Qt version: Qt_5_7_1 or above
OpenSSL 1.0.x or above the for SSL feature

How to use it:
1. I simply run the mysql_conn_test_database.sql SQL script file to create a test database on the remote server.
2. Set the hostname or IP, port number, username and password. You migth need to create a new database user for this purpose.
[You will need to create SSL certificates for the database server and client in order to test SSL Feature on the MySQL Server.]
3. If everthing is set just simple build and run the project in your QtCreator.

If everything goes well you will recieve the following feedback from your terminal:


QSqlDatabase connection test tool was created and written by Roland Ihasz and it is licensed under the GNU General Public License (GPL) Version 2 or above.

Check out on GitHub. https://github.com/lnrsoft/QSqlDatabase-connection-test-tool

 mysql_db_connection_test.pro

 main.cpp

 mysql_conn_test_database.sql

Alternatively, use the following shorter source code to check the connection without any sql query.
 QSqlDatabase connection test tool without query

[SOLVED] QSQLDATABASE: QMYSQL DRIVER NOT LOADED ON OSX AND LINUX

After spending a quite a bit of time to find the solution of this often-occurring
QMYSQL driver not loaded problem mainly after installing Qt installation in a new software environment, So I thought I am going to share my best practice to fix this issue.
I wasn’t able to establish database connection even if I received the list of available drivers:

QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QPSQL
QSqlDatabase: QMYSQL driver not loaded

The following simple method helps to fix the problem.
On OSX system just simple install or re-install mysql using the flowing command. I usually prefer Homebrew as it fulfils most my requirements and using MacPort when I really no other options available.

then place the following libmysqlclient.18.dylib file to the path below:

On different Linux distributions I usually apt install or yum install the MySQL package basically the only thing I need to make sure that place the libmysqlclient.18.dylib file to the following path:

This method solves the QMYSQL driver not loaded issue and allows me to establish database connection, it might work on Windows system as well, however I had not opportunity to try before.
Please, let me know if this method also working for you by dropping a line.

Download libmysqlclient.18.dylib

HOW TO RETURN A STRING EQUIVALENT OF THE NUMBER N USING QT.

QString QString::number(double n, char format = ‘g’, int precision = 6) returns a string equivalent of the number n, formatted according to the specified format and precision.

Let’s see the following example.
There are 3 double values x, y, z.
We want to return the result of the following equation:
(x / z) * (5.961 / y)
We also want to ask the user to set the desired precision of the result.

Here is how I do with Qt.
You can also Fork the complete qt project from my GitHub.
* note = there are many ways to solve this issue, much simpler, but this time I want to demonstrate how we do in Qt.

Argument Formats
In member functions where an argument format can be specified (e.g., arg(), number()), the argument format can be one of the following:

Format            Meaning

e                      format as [-]9.9e[+|-]999

E                      format as [-]9.9E[+|-]999

f                       format as [-]9.9

g                      use e or f format, whichever is the most concise

G                     use E or f format, whichever is the most concise

A precision is also specified with the argument format. For the ‘e’, ‘E’, and ‘f’ formats, the precision represents the number of digits after the decimal point. For the ‘g’ and ‘G’ formats, the precision represents the maximum number of significant digits (trailing zeroes are omitted).

How to return a string equivalent of the number n using Qt was written by Roland Ihasz>, you can modify or distribute. You can do anything you want with this software, just don’t say you wrote it.

More info on   doc.qt.io

Accessing Inherited Functions – HackerRank Challenge Solved in C++

Accessing Inherited Functions – HackerRank Challenge Solved in C++

You and run the code from your terminal using the following commands:

Variable Sized Arrays – HackerRank Challenge Solved in C++

Variable Sized Arrays – HackerRank Challenge Solved in C++

Set STL – HackerRank Challenge Solved in C++

Set – STL – HackerRank Challenge Solved in C++

HackerRank C++ Virtual Functions Challenge

HackerRank C++ Virtual Function Challenge

HackerRank Challenge – Find out the area of a rectangle using C++ inheritance

Rectangle Area HackerRank Challenge

..and a bit longer version.

How to display an image on a QtWidget


There is a simple method to insert images such as a png file using QPixmap. I personally prefer to use a QLabel to show simple images on QWidget, particularry if there is no any other fancy requirements.
Basically you can locate the QLabel anywhere on your QWidget. You will find the pixelmap option at the text option section in your Qt Creator, right below the textFormat. When you click on the Value section you’ll find a small arrow pointing down.
Simple click on it, then choose your png file.

If you just simple want to display an image to the QWidget, I found the following option works well. You just need to insert the path of the image file right after the

member function in your main parent widget, then insert the following source code.

If you know other method to display an image on a QtWidget Please, let me know by dropping a line, I can add it to this post if it is relevant and you agree to do.

[SOLVED] How to re-flash the corrupted BIOS of a Dell Laptop using a USB drive

This is the latest version of the How re-flash the corrupted BIOS of a Dell Inspiron Laptop article.

Repair-Corrupted-BIOS-Firmware

There is, however, no guarantee that the following method will also work for you, as reading this sentence you agree that I am taking no responsibility of any damage caused by the following procedure.

CORRUPTED BIOS AND HOW TO FLASH IT?
How to Recover from a disastrous BIOS update?
How to Flash a Corrupted Dell Inspiron Laptop BIOS?

Simply follow this procedure to re-flash failed BIOS update on a Dell Inspiron (n5010 model in my case) laptop. Presumably the following method also works on almost all other Dell models.

Phase 1.

  • Rename the newly created N5010A15.HDR and N5010A15.ROM files to N5010.HDR and N5010.ROM.
  • Format an USB thumb-drive to FAT and copy the N5010.HDR, N5010.ROM files on it. You do not need to create bootable USB drive.
    *UPDATE: most of the time I hear feedback about this method people add a comment that they formatted their USB thumb-drive to FAT16 as the FAT32 file system did NOT work.

Phase 2.

  • Shutdown your faulty laptop if is is still running with the black screen.
  • Remove the battery
  • Remove the CMOS battery
  • Disconnect the power supply.
  • Insert the USB drive in the USB port.
    *UPDATE: According to the feedback on this method most people use the left USB socket, as the rest of the USB sockets might not functioning at this state.

*Note: There are few cases reported about not active USB ports. Simply try to use other USB port if you notice or suspect that the system cannot read the USB drive from the port you plugged it. Use USB drive with activity LED if you have one, the blinking LED will confirm that the system reads data from your USB drive.

Phase 3.

  • Press and keep hold the END key on the keyboard for your faulty laptop.
  • Plug the DC power connectors (power plug) into the laptop.
  • After a few seconds your faulty laptop will start itself and will re-flash its corrupted BIOS and automatically reboot.
  • You can release the END key after the flashing process started. A USB drive with an activity LED can confirm that the BIOS flashing process started. The complete re-flashing process will take no longer than 60 maximum 90 seconds.

Your comments and suggestions would be greatly appreciated.

 


WARNING! 
I am taking no responsibility of any damage caused by the following NOT TESTED procedure. Try this PhoenixTool method when the /writeromfile and /writehdrfile commands are not give you any result.

This procedure never been tested by myself, however quite a few people were asked me about how to extract ROM files from other system BIOS files without the /writeromfile and /writehdrfile commands mentioned above in my step by step guide. 

Let’s take an example of Inspiron N7010 BIOS. In this case the usual /writeromfile and /writehdrfile commands will not work.
You’ll need 7-Zip or Universal Extractor and PhoenixTool to extract/create rom files from the R301250.exe System BIOS file.

Phase 1.

  • Download the R301250.exe (2969 KB) file from the official source ( http://www.dell.com/support/home/uk/en/ukbsdt1/drivers/driversdetails?driverId=R301250 )

Phase 2.

  • Extracting the 7010_A11.EXE (7944 KB) file from the original R301250.exe (2969 KB) file using Universal Extractor (source: https://www.legroom.net/software/uniextract ). In numerous cases 7-Zip able extract exe files as well.
    extracting

    the result

Phase 3.

    • Extracting *.rom , *.bin files using PhoenixTool 2.73 (Phoenix/Dell/EFI SLIC Mod v2.73 , source: https://forums.mydigitallife.net )
    • In the PhoenixTool select and add your 7010_A11.EXE file as the Original BIOS, then set Manufacturer to Dell and add the DELL.BIN SLIC file (this can be found in PhoenixTool273/SLIC21 folder)
    • Note! In order to extract rom files, you’ll need to tick/select from Advanced options under control options “Extract modules when verifying” then press done and verify. It will then create a DUMP folder next to your 7010_A11.EXE file.  Microsoft .NET Framework 3.5 required for PhoenixTool 2.73.
      PhoenixTool 2.73
      result

Useful resources:

  1. AT24C01A EEPROM datasheet
  2. DELL EMC System Update for Windows and Linux
  3. Flashrom or Qflashrom
  4. Superiotool – Detect which Super I/O you have on your mainboard
  5. Official Dell BIOS Recovery options
  6. Dell: What is BIOS and How to Download and Install the latest BIOS?
  7. Dell: 64-bit BIOS Installation Utility
  8. RW-Everything
  9. PhoenixTool 2.73

The reason behind writing this BIOS recovery article is provide some helpful info/advice/starting point to everyone facing with the same issue. If you feel that this procedure helped you to save time / money as you were able to successfully recover your corrupted BIOS, you can make a small donation to my BTC address 15JmQsaxyaxsEZf5WJVDxibLkLJFWtz83y . Your support is greatly appreciated.


This work (How to re-flash the corrupted BIOS of a Dell Laptop using only a USB drive, by Roland Ihasz) is free of known copyright restrictions.