Color dialog for QGuiApplication (Qt 5.1) [SOLVED]

  • Hello,

    I'm coding a simple (in terms of UI) application for OpenGL rendering using QGuiApplication/QWindow. Human interaction is exclusively via keyboard and mouse (i.e. no UI elements). The problem is to open a color picker/dialog when a specific key is pressed (and of course receive a QColor). Previously, using QWidgets, I would simply use QColorDialog:

    QColor color = QColorDialog::getColor();

    If there's a similar one-line approach for QWindow apps, then stop reading and please let me know what this is.

    I'm aware of a similar QtQuick color dialog, but I'm unfamiliar with QtQuick and QML. Assuming that I use the QML code provided "here": is there a simple way (i.e. few lines of code) to use this in my application? Google and the qt documentation doesn't give me a straight answer here I'm afraid.

    Furthermore, using the QML code for the simple color dialog, I get the following error: unknown component (M300) at ColorDialog, line 4. I'm not sure what or where I need to include something to get rid of this.

    SOLVED: after some reading, it turns out QQuickView can be used to run the QML application within my c++ app. It's a bit more code than the previous QWidget solution, since the colour needs to be fetched from the quit signal in the colour dialog app, but not too complicated either.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.