Sending struct to QDialog
-
How would the setup be?
I define a struct in both the MainWindow and the Dialog.
typedef struct { bool Condition1; bool Condition2; bool Condition3; QString String1; QString String2; QString String3; } DialogStruct; Q_DECLARE_METATYPE(DialogStruct);Then create one empty
Struct DialogStruct;Fill it with data
DataToDialog.String1 = ""; DataToDialog.String2 = ""; DataToDialog.String3 = ""; DataToDialog.Condition1 = true; DataToDialog.Condition2 = true; DataToDialog.Condition3 = true;Then i want to send
DataToDialogTo the dialogs struct. How do i do this?
-
Hi,
One possibility:
MyDialog myDialog; myDialog.setStructure(myStructure); myDialog.exec();A different one:
MyDialog myDialog(myStructure); myDialog.exec(); -
Hi,
One possibility:
MyDialog myDialog; myDialog.setStructure(myStructure); myDialog.exec();A different one:
MyDialog myDialog(myStructure); myDialog.exec();@SGaist said in Sending struct to QDialog:
Hi,
One possibility:
MyDialog myDialog; myDialog.setStructure(myStructure); myDialog.exec();A different one:
MyDialog myDialog(myStructure); myDialog.exec();I seem to be able to create them in Main and Dialog. Also use them to point data to their contents but it complains when i want to point the data towards the dialog?
-
@SGaist said in Sending struct to QDialog:
Hi,
One possibility:
MyDialog myDialog; myDialog.setStructure(myStructure); myDialog.exec();A different one:
MyDialog myDialog(myStructure); myDialog.exec();I seem to be able to create them in Main and Dialog. Also use them to point data to their contents but it complains when i want to point the data towards the dialog?
@RainyDays said in Sending struct to QDialog:
but it complains when i want to point the data towards the dialog?
What does this mean?
-
@RainyDays said in Sending struct to QDialog:
but it complains when i want to point the data towards the dialog?
What does this mean?
@Christian-Ehrlicher said in Sending struct to QDialog:
@RainyDays said in Sending struct to QDialog:
but it complains when i want to point the data towards the dialog?
What does this mean?
"No viable conversion from Mainstruct to Dialogstruct"
Where Mainstruct is a struct in the MainWindow and Dialogstruct is a struct in the DialogWindow.
Both are set up like this
typedef struct { bool Condition1; bool Condition2; bool Condition3; QString String1; QString String2; QString String3; } -
@Christian-Ehrlicher said in Sending struct to QDialog:
@RainyDays said in Sending struct to QDialog:
but it complains when i want to point the data towards the dialog?
What does this mean?
"No viable conversion from Mainstruct to Dialogstruct"
Where Mainstruct is a struct in the MainWindow and Dialogstruct is a struct in the DialogWindow.
Both are set up like this
typedef struct { bool Condition1; bool Condition2; bool Condition3; QString String1; QString String2; QString String3; }@RainyDays said in Sending struct to QDialog:
Both are set up like this
Which is wrong - you need one struct definition.
You really should start with the basics of c(++) before fiddling around with Qt.
-
@RainyDays said in Sending struct to QDialog:
Both are set up like this
Which is wrong - you need one struct definition.
You really should start with the basics of c(++) before fiddling around with Qt.
Informative, well chosen.
I hear QT is a mysterious device that could be dangerous for those who have not chosen the right path from the beginning.
Thanks for the warning :) -
Informative, well chosen.
I hear QT is a mysterious device that could be dangerous for those who have not chosen the right path from the beginning.
Thanks for the warning :)@RainyDays said in Sending struct to QDialog:
I hear QT is a mysterious device that could be dangerous for those who have not chosen the right path from the beginning.
If you think... but i only said that at least basic c++ knowledge is needed since Qt is a c++ library.
-
@RainyDays said in Sending struct to QDialog:
I hear QT is a mysterious device that could be dangerous for those who have not chosen the right path from the beginning.
If you think... but i only said that at least basic c++ knowledge is needed since Qt is a c++ library.
@Christian-Ehrlicher
The first time is always the hardest time and for me this was too many years ago :)
Takes a while to get the engine running again!
But why stop when you reach an obstacle? Just ask for a friendly helping hand?I´m really sure though i need to define the structs in each of the header files.
Otherwise the dialog does not know what it´s struct is...right? -
One single definition.
Put that in a different header that both can include.
-
That's the goal: one single source of truth.