SOLVED: Connect to SQL Database from a custom widget plugin

  • Hello,
    I've created a custom widget plugin and includet it into QTCreator so I can use it from the Widgetbrowser in QTDesigner to create my gui. Now I want to extend my custom widget to connect to a SQL Database to show data of the Database in my custom widget. So I write a method to connect to the Database und read the data. but when I start compiling the custom widget plugin I get many errors. is it possible to use SQL in a custom widget plugin?

    my profile looks like this:
    @QT += widgets designer
    QT += sql

    QTDIR_build {

    This is only for the Qt build. Do not use externally. We mean it.

    PLUGIN_TYPE = designer
    } else {

    Public example:

    CONFIG += plugin
    TEMPLATE = lib

    TARGET = $$qtLibraryTarget($$TARGET)

    target.path = $$[QT_INSTALL_PLUGINS]/designer
    INSTALLS += target


    HEADERS = customwidgetplugin.h
    SOURCES = customwidgetplugin.cpp
    OTHER_FILES +=newlabel.json


  • solved: switched to release mode and compiled it with no errors

  • Lifetime Qt Champion


    Don't forget to also update the thread's title to solved (which it's not really since you still have a problem in debug build)

Log in to reply

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