How to give a delay in loop execution using Qt

EDIT (removed wrong solution). EDIT (to add this other option): Another way to use it would be subclass QThread since it has protected *sleep methods. QThread::usleep(unsigned long microseconds); QThread::msleep(unsigned long milliseconds); QThread::sleep(unsigned long second); Here’s the code to create your own *sleep method. #include <QThread> class Sleeper : public QThread { public: static void usleep(unsigned … Read more

Qt5 QML module is not installed

I’ll try to answer your questions: I think installed means they are located in the proper paths, so that they can be found at runtime You should not necessarily create/build a QmlExtensionPlugin for that purpose. You can also use as a module plain QML files in one directory with a qmldir describing this module. It … Read more

What’s the difference in Qt between setVisible, setShown and show/hide

show() is just a convenience function for setVisible(true). Similarly hide() is equivalent to setVisible(false) Internally, the same code is used to render your view. See http://doc.qt.io/archives/qt-4.7/qwidget.html#show as an example. According to it, void QWidget::show () [slot] Shows the widget and its child widgets. This function is equivalent to setVisible(true). You’ll find lots of such functions … Read more

How to use QTimer

Other way is using of built-in method start timer & event TimerEvent. Header: #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); private: Ui::MainWindow *ui; int timerId; protected: void timerEvent(QTimerEvent *event); }; #endif // MAINWINDOW_H Source: #include “mainwindow.h” … Read more

Build Qt Tests with CMake

Here is an example of using cmake 2.8.11 and Qt5.2. Note that cmake now supports testfiles with a .moc-include at the bottom. CMakeLists.txt: cmake_minimum_required(VERSION 2.8.11) project(foo) enable_testing() # Tell CMake to run moc when necessary: set(CMAKE_AUTOMOC ON) # As moc files are generated in the binary dir, tell CMake # to always look for includes … Read more

How to define an OnClick event handler for a button from within Qt Creator?

In the designer, add Push Button to the form right click the Push Button select “Go to slot…” select “clicked()” signal done The terms are different from .NET, so in this case we are talking about signals and slots, and the signal emitted when QPushButton is clicked is called clicked() instead of OnClick. Reading the … Read more

Why is QsslSocket working with Qt 5.3 but not Qt 5.7 on Debian Stretch?

TL;DR Debian Stretch is shipped with OpenSSL 1.1; Qt uses OpenSSL 1.0; give Qt what it needs: apt install libssl1.0-dev Detailed answer From this answer about OpenSSL and Qt, I found a hint and I displayed SSL library version used for compile-time and run-time using: qDebug()<<“SSL version use for build: “<<QSslSocket::sslLibraryBuildVersionString(); qDebug()<<“SSL version use for … Read more

Initially hidden control in Qt Creator

You can’t. The visible property seems to be voluntarily removed from the property editor of Qt Designer and you can’t add it back. You can add the property manually to the .ui file by adding the following XML block inside the node for the widget you want to hide: <property name=”visible”> <bool>false</bool> </property> But the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)