Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to get result from dialog to main windows
Forum Updated to NodeBB v4.3 + New Features

How to get result from dialog to main windows

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ahmet4697
    wrote on last edited by ahmet4697
    #1

    Hello I maked a dialog with qt creator (Template=Designer Form And Class)
    I put a lineEdit on my dialog.And a Accept OK button.
    in my Main Window ı want get lineEdit of Dialog text.
    I have written like this but didnt work
    void MainWindow::on_pushButton_clicked()
    {
    if(!dialog)
    dialog=new MyDialog(this);
    if(dialog->exec())
    {
    QMessageBox::information(this,"Title",dialog->lineEdit->text());

    }
    }

    Error:
    C:\Users\falco-user\Desktop\cpp\qtdeneme\untitled2\mainwindow.cpp:44: error: 'class MyDialog' has no member named 'lineEdit'
    QMessageBox::information(this,"Title",dialog->lineEdit->text());
    ^

    1 Reply Last reply
    0
    • napajejenunedk0N Offline
      napajejenunedk0N Offline
      napajejenunedk0
      wrote on last edited by
      #2

      Your MyDialog should have a UI file and a UI class. You should add a public getter function to MyDialog that gets the text of the line edit of the UI class. It is not recommended that you expose internals of the implementation of a class in this way. So, your getter should look like:

      QString MyDialog::someText() const
      {
          return m_ui->lineEdit->text();
      }
      
      1 Reply Last reply
      0
      • A Offline
        A Offline
        ahmet4697
        wrote on last edited by
        #3

        Thank you very much

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved