How to print to console when using Qt

If it is good enough to print to stderr, you can use the following streams originally intended for debugging: #include<QDebug> //qInfo is qt5.5+ only. qInfo() << “C++ Style Info Message”; qInfo( “C Style Info Message” ); qDebug() << “C++ Style Debug Message”; qDebug( “C Style Debug Message” ); qWarning() << “C++ Style Warning Message”; qWarning( … Read more

STL or Qt containers?

This is a difficult to answer question. It can really boil down to a philosophical/subjective argument. That being said… I recommend the rule “When in Rome… Do as the Romans Do” Which means if you are in Qt land, code as the Qt’ians do. This is not just for readability/consistency concerns. Consider what happens if … Read more

QLabel: set color of text and background

The best and recommended way is to use Qt Style Sheet. Docs: Qt 5 Style Sheet, Qt 6 Style Sheet. To change the text color and background color of a QLabel, here is what I would do : QLabel* pLabel = new QLabel; pLabel->setStyleSheet(“QLabel { background-color : red; color : blue; }”); You could also … Read more

Auto-expanding layout with Qt-Designer

After creating your QVBoxLayout in Qt Designer, right-click on the background of your widget/dialog/window (not the QVBoxLayout, but the parent widget) and select Lay Out -> Lay Out in a Grid from the bottom of the context-menu. The QVBoxLayout should now stretch to fit the window and will resize automatically when the entire window is … Read more

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