QUiLoader with signals and slots

  • My project is all based on QUiLoader, ie, all interfaces are generated dynamically.
    I created a form with Qt Creator for the user to enter the parameters for the database connection. When clicked [OK] data from QLineEdit should be passed to the QSettings object. How to using signals and slots with QUiLoader?

    Below, my methods of reading and writing settings. writeSettings calls the settings form.

    @QHash DataAccess::readSettings()
    QSettings connecsettings( QSettings::IniFormat, QSettings::SystemScope, "Freedom", "TecTracker");

    QHash<QString, QVariant> *parameter = new QHash<QString, QVariant>();



    parameter->insert("host", connecsettings.value("host", ""));
    parameter->insert("port", connecsettings.value("port", 5432);
    parameter->insert("database", connecsettings.value("database"));
    parameter->insert("user", connecsettings.value("user", "postgres"));
    parameter->insert("passw", connecsettings.value("passw", "postgres"));


    return parameter;

    void DataAccess::writeSettings(QSettings* settings)
    DynamicQtWidgets* guigenerator = new DynamicQtWidgets("configconnec.ui", this);
    QDialog *confconnec = guigenerator->createWidget();

    Searching the forum I found a similar "topic":http://qt-project.org/forums/viewthread/31605. but the answers did not help me. There is an answer stating that signals and slots can be implemented in the ui file. How to do this with Qt Creator? Would be in the "Signals & Slots Editor" tab of the designer mode?

    !http://i58.tinypic.com/2mgw3l0.png(Signals & Slots Editor)!

    1. Get the reference of lineEdit and Button(which you click ok)
    2. Write your own slot in your own class file
    3. Connect the either lineEdit or Button signal with your slot defined in Step#2,
    4. Inside your slot, do whatever the custom logic required

  • It is not possible to do this in the ui file? Ie I create the slot in my class, but the connection to the signal leaving in the ui file?

    Something like

    @ <sender>qdbb_okcancel</sender>

    I wanted to avoid manipulation of the GUI in code

Log in to reply

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