crossplatform.ru

Здравствуйте, гость ( Вход | Регистрация )


  Ответ в Передача данных
Введите ваше имя
Подтвердите код

Введите в поле код из 6 символов, отображенных в виде изображения. Если вы не можете прочитать код с изображения, нажмите на изображение для генерации нового кода.
 

Опции сообщения
 Включить смайлы?
Иконки сообщения
(Опционально)
                                
                                
  [ Без иконки ]
 


Последние 10 сообщений [ в обратном порядке ]
maranath Дата 22.6.2011, 23:19
  Выдает ошибку
../mymdi/mainwindow.cpp: In member function ‘void MainWindow::Sl_Sprusers()’:
../mymdi/mainwindow.cpp:49:54: error: no matching function for call to ‘SP_users::SP_users(QString)’
../mymdi/sp_users.h:20:14: note: candidates are: SP_users::SP_users(QWidget*, QString)
../mymdi/sp_users.h:14:1: note: SP_users::SP_users(const SP_users&)

Ругается на Dialog* dialog = new Dialog(ui->lineEdit->text())
Выдает ошибку
../mymdi/mainwindow.cpp: In member function ‘void MainWindow::Sl_Sprusers()’:
../mymdi/mainwindow.cpp:49:54: error: no matching function for call to ‘SP_users::SP_users(QString)’
../mymdi/sp_users.h:20:14: note: candidates are: SP_users::SP_users(QWidget*, QString)
../mymdi/sp_users.h:14:1: note: SP_users::SP_users(const SP_users&)

SP_users *spu = new SP_users(ui->lineEdit->text());
...



explicit SP_users(QWidget *parent = 0, QString textLine="");
...


SP_users::SP_users(QWidget *parent, QString textLine) :
QMainWindow(parent),
ui(new Ui::SP_users)

Выдает ошибку:
mainwindow.cpp:-1: In member function ‘void MainWindow::Sl_Sprusers()’:
mainwindow.cpp:49: ошибка: no matching function for call to ‘SP_users::SP_users(QString)’
sp_users.h:20: candidates are: SP_users::SP_users(QWidget*, QString)
sp_users.h:14: SP_users::SP_users(const SP_users&)
Dimix Дата 16.2.2011, 12:42
  Dovgon Супер все работает как надо Спасибо
Dimix Дата 14.2.2011, 18:08
  Я решил эту проблему вот так постараюсь объяснить Создаю два окна первое Win1 второе Win2 в Win2 делаю public:QlineEdit* edit; в Win1 подключаю заголовочный файл #include "Win2" в Win1 делаю слот для отображения окна Win2 в созданном слоте прописываю:
Win2* bla = new Win2;
bla->edit.setText(говорю что хочу передать);
bla->show();
this->close();
Как то так!
Dovgon Спасибо я попробую.
Dovgon Дата 14.2.2011, 8:11
  можно так:

void MainWindow::on_pushButton_clicked(){
       Dialog* dialog = new Dialog(ui->lineEdit->text(), comboBox->currentText());
       dialog->show();
       ....
}

.....

class Dialog : public QDialog{
        Q_OBJECT

public:
        explicit Dialog(QWidget *parent = 0, QString textLine="", QString textCombo="");
        .......
};
..........

Dialog::Dialog(QWidget *parent, QString textLine, QString textCombo) : QDialog(parent), ui(new Ui::Dialog){
         ui->setupUi(this);
         .....
}

попробуй.
Алексей1153 Дата 14.2.2011, 8:06
  Dimix, у тебя по stack overflow всё не валится, случаем ? Ты в конструкторе одного класса создаёшь экземпляр другого - перекрёстно. Уж определись, кто из окон будет дочерним
сорри, невнимательно посмотрел.
Dimix Дата 14.2.2011, 3:38
  Немогу спокойно спать. Хочу понять как передавать данные.
Создал пустой проэкт Qt datastream
Раскрывающийся текст
HEADERS += \
mainwindow.h \
dialog.h

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

FORMS += \
mainwindow.ui \
dialog.ui

Создал 2 класса форм Qt Designer
DIALOG
Раскрывающийся текст
#ifndef DIALOG_H
#define DIALOG_H#include <QDialog>

namespace Ui {
class Dialog;
}

class Dialog : public QDialog
{
Q_OBJECT

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

private:
Ui::Dialog *ui;
};

#endif // DIALOG_H
Раскрывающийся текст
#include "dialog.h"
#include "ui_dialog.h"

#include "mainwindow.h"
#include "ui_mainwindow.h"

Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{
ui->setupUi(this);

MainWindow* main = new MainWindow;

ui->listWidget->addItem(main->ui->lineEdit->text());
ui->listWidget->addItem(main->ui->comboBox->currentText());
}

Dialog::~Dialog()
{
delete ui;
}
Раскрывающийся текст
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>282</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QListWidget" name="listWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>40</y>
<width>261</width>
<height>192</height>
</rect>
</property>
</widget>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>10</x>
<y>250</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Back</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_2">
<property name="geometry">
<rect>
<x>200</x>
<y>250</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Close</string>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>110</x>
<y>20</y>
<width>61</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Return label</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>

MAINWINDOW
Раскрывающийся текст
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
Q_OBJECT

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


Ui::MainWindow *ui;

private slots:
void on_pushButton_clicked();
};

#endif // MAINWINDOW_H
Раскрывающийся текст
#include "mainwindow.h"
#include "ui_mainwindow.h"

#include "dialog.h"
#include "ui_dialog.h"

MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}

MainWindow::~MainWindow()
{
delete ui;
}

void MainWindow::on_pushButton_clicked()
{
Dialog* dialog = new Dialog;
dialog->show();
return ui->lineEdit->text();
this->close();
}
Раскрывающийся текст
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>142</width>
<height>155</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QLineEdit" name="lineEdit">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>113</width>
<height>20</height>
</rect>
</property>
</widget>
<widget class="QComboBox" name="comboBox">
<property name="geometry">
<rect>
<x>10</x>
<y>40</y>
<width>111</width>
<height>22</height>
</rect>
</property>
<item>
<property name="text">
<string>Clear</string>
</property>
</item>
<item>
<property name="text">
<string>Dimix</string>
</property>
</item>
<item>
<property name="text">
<string>Shket</string>
</property>
</item>
</widget>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>50</x>
<y>80</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Send</string>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>142</width>
<height>21</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>

И создал файл исходных текстов main
Раскрывающийся текст
#include "mainwindow.h"
#include "ui_mainwindow.h"

int main(int argc, char** argv)
{
QApplication app(argc, argv);

MainWindow* main = new MainWindow;
main->show();

return app.exec();
}

Хочу предать текст из comboBox и lineEdit другой форме на listWidget получаю пустые значения.
Как правильно?

Просмотр темы полностью (откроется в новом окне)
RSS Текстовая версия Сейчас: 19.4.2024, 6:01