Generate a Visual Studio 2010 project file from a qmake pro file
qmake -spec win32-msvc2010 -tp vc <project_file>.pro
qmake -spec win32-msvc2010 -tp vc <project_file>.pro
QML_SHOW_FRAMERATE variable can be used for performance information. It prints the time spent each frame to the console.
DEFINE_BOOL_CONFIG_OPTION(frameRateDebug, QML_SHOW_FRAMERATE)
see src/declarative/util/qdeclarativeview.cpp
using:
...
if (frameRateDebug())
{
// do something
}
Also this variable can be set in Qt Creator (see the “Run Environment” subsection in the project’s “Run Settings” tab).
QImage is not good choice for scaling images (like QImage::load() + QImage::scaled()).
QImageReader API is better approach than loading full image into memory and stretching it there. QImageReader API allows to set needed scaling limitations first and then load it. The image will be scaled as part of loading process and there is no needs to allocate memory for full size image.
pattern: QImageReader::setScaledSize() + QImageReader::read()
class MainWindow : public QMainWindow { Q_OBJECT; public: MainWindow(QWidget *parent = 0) : QMainWindow(parent) { QSettings settings; restoreGeometry(settings.value("mainWindowGeometry").toByteArray()); // create docs, toolbars, etc... restoreState(settings.value("mainWindowState").toByteArray()); } void closeEvent(QCloseEvent *event) { QSettings settings; settings.setValue("mainWindowGeometry", saveGeometry()); settings.setValue("mainWindowState", saveState()); } }; int main(int argc, char *argv[]) { QApplication a(argc, argv); QCoreApplication::setOrganizationDomain("OrgDomain"); QCoreApplication::setOrganizationName("OrgName"); QCoreApplication::setApplicationName("AppName"); QCoreApplication::setApplicationVersion("1.0.0"); MainWindow w; w.show(); return a.exec(); }
The above code will save and restore window position, size, toolbar visibility, toolbar docking area, dock states, locations and sizes. It saves using QSettings which will store your settings in a platform correct way.
if (fruit== "apple") { ... } // hidden malloc
if (fruit== QLatin1String("apple")) { ... } // fast and mentions encoding
if (foo.startsWith("(" + type + ") 0x"))
if (foo.startsWith("(" % type % ") 0x"))