I'd like to access some functions of a dialog-type widget from my mainwindow.cpp.
I've created a simple function in the widget class that returns an int, which looks like this:
dialog.h:
public:
int getRowCountData();
dialog.cpp:
int Dialog::getRowCountData()
{
return ui->tableWidget->rowCount();
}
Usage:
my mainWindow.h:
private:
Dialog *dialog;
my mainwindow.cpp:
dialog = new Dialog;
int count = dialog->getRowCountData(); <<<<<--------------this throws a read access error!
code: 0xc0000005 read access violation at: 0x0 flas=0x0
how am I to use another widget's public functions such as this simple one?
I must not be referencing the integer I'd like to set using the rowcount function. Signals and slots have worked great for me in the past when using them to transfer data between widgets, but I'd like to stick to using my dialog widget's function like this if I can.
I came about this method for retrieving data on my other widget by posting this question: AccessingQTableWidget's data from another class. @Chernobyl maybe you have some further insight to provide?
Thanks in advance!
dialogpointer there is 0. Why, is not apparent from the question.new Dialoganddialog->, and hit F2 on bothdialognames. Do they take you to the same place (probably the declaration in .h file of the class)? Set breakpoints or add debug prints for both to see ifdialogreally is created before you try to use it.