About dialogs



  • Hi,

    I'm new about using Qt and I'm trying creat dialog windows.I created a main dialog window succesfully but the lower window was not succes.Code as follows in mainwindow.cpp

    @#include<mydialog.h> //I created a window as myDialog in qt design and made include in mainwindow.cpp
    void MainWindow::on_actionMain_triggered() //I went to the slot in mainwindow
    {
    myDialog mDialog ;
    mDialog.setModal(true);
    mDialog.exec();
    }
    @
    When I deleted codes in slot and run ,project work.wrongs as follows;

    compile output;

    **jom: C:\Users\sefa\Desktop\QT\projeler\designer_kullanimi_2\Makefile.Debug [debug\designer_kullanimi_2.exe] Error 1120
    jom: C:\Users\sefa\Desktop\QT\projeler\designer_kullanimi_2\Makefile [debug] Error 2
    16:46:22: The process "C:\Qt2\Qt5.1.1\Tools\QtCreator\bin\jom.exe" exited with code 2.
    Error while building/deploying project designer_kullanimi_2 (kit: Desktop Qt 5.1.1 MSVC2012 OpenGL 64bit)
    When executing step 'Make'

    issues;

    mainwindow.obj:-1: error: LNK2019: unresolved external symbol "public: __cdecl myDialog ::myDialog (class QWidget *)" (??0myDialog @@QEAA@PEAVQWidget@@@Z) referenced in function "private: void __cdecl MainWindow::on_actionMain_triggered(void)" (?on_actionMain_triggered@MainWindow@@AEAAXXZ)

    debug\designer_kullanimi_2.exe:-1: error: LNK1120: 2 unresolved externals



  • Hi,
    Did you also include the dialog in your project file? The compiler is not able to find your constructor of the dialog class.
    Greetz



  • in project file code
    @#-------------------------------------------------

    Project created by QtCreator 2013-12-02T16:31:01

    #-------------------------------------------------

    QT += core gui

    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

    TARGET = designer_kullanimi_2
    TEMPLATE = app

    SOURCES += main.cpp
    mainwindow.cpp
    mydialog.cpp \

    HEADERS += mainwindow.h
    mydialog.h \

    FORMS += mainwindow.ui
    mydialog.ui \

    @


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Can you show the mydialog.h content ?



  • thanks,
    @#ifndef MYDIALOG_H
    #define MYDIALOG_H

    #include <QDialog>

    namespace Ui {
    class myDialog;
    }

    class myDialog : public QDialog
    {
    Q_OBJECT

    public:
    explicit myDialog(QWidget *parent = 0);
    ~myDialog();

    private:
    Ui::myDialog *ui;
    };

    #endif // MYDIALOG_H
    @


  • Lifetime Qt Champion

    And how does the cpp look like ?



  • I have not done anything cpp fiile without including mydialog.h.Problem may be do to the location of the debug and release file or installation.What do you think about this.I'm sorry to keep you busy

    @#include "mainwindow.h"
    #include <QApplication>
    #include<mydialog.h>

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    return a.exec&#40;&#41;;
    

    }@


  • Lifetime Qt Champion

    including mydialog.h in main.cpp won't change anything. You have the constructor from myDialog that seems to be missing. That's why I've asked for the mydialog.cpp file



  • Try right clicking on the project name and selecting run qmake.


Log in to reply
 

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