Signal doesn't work properly
-
@gabor53
you need a pointer to your MainWindow object and call AddView() on it instead.
I guess somewhere you have already created a MainWindow?@raven-worx
Yes, I have MainWindow as a class. -
@raven-worx
Yes, I have MainWindow as a class.@gabor53
i meant an instance of the MainWindow already.
Since you named it "MainWindow" you might want to create i tin the main() function.Then somewhere you need to make the connection at a point where you have pointers of both objects/windows.
You could also directly connect the Review window with the MainWindow (declare AddView() as slot):
connect(mReviewWindow,&Review::RecAdded,mMainWindow,&MainWindow::AddView); -
@gabor53
you need a pointer to your MainWindow object and call AddView() on it instead.
I guess somewhere you have already created a MainWindow?@raven-worx
I did the following in Review.cpp:{ qDebug() << "Entered updateTable!"; MainWindow *mMainWindow = new MainWindow(this); mMainWindow->Addview(); } It goes to Addview() in MainWindow.cpp, but after processing``ui->tableView->setModel (smodel);`
it jumps back tovoid Review::updateTable()
and the actual table in MainWindow is not updated. -
Deleted my previous post as it was wrong, I'm surprised it compiles with duplicate symbols as mMainWindow seems to be in your code
what you are trying to do is insert a row in the db, then delete your model completely and rebuild it from scratch. would it be easier to pass the new line as arguments to RecAdded and use them to append the row?
to put my solution here I need to know the type of:
sIDReviewnameReviewfileByteArray(QByteArray?)descriptionReviewmonthReview(int?)dayReview(int?)yearReview(int?)historyReviewageReview(int?)notesReviewcolorReviewmaterialReviewSignedbyReview(QString?)whatReview
EDIT:
it jumps back to
it's not jumping back, you are creating a new MainWindow and it's constructor is calling a new review, it's not a jump back, it's a different instance
-
Deleted my previous post as it was wrong, I'm surprised it compiles with duplicate symbols as mMainWindow seems to be in your code
what you are trying to do is insert a row in the db, then delete your model completely and rebuild it from scratch. would it be easier to pass the new line as arguments to RecAdded and use them to append the row?
to put my solution here I need to know the type of:
sIDReviewnameReviewfileByteArray(QByteArray?)descriptionReviewmonthReview(int?)dayReview(int?)yearReview(int?)historyReviewageReview(int?)notesReviewcolorReviewmaterialReviewSignedbyReview(QString?)whatReview
EDIT:
it jumps back to
it's not jumping back, you are creating a new MainWindow and it's constructor is calling a new review, it's not a jump back, it's a different instance
-
@VRonin
review.h
review.cpp
mainwindow.cpp
Thank you. -
@VRonin
sIDReview (QString)
nameReview (QString)
fileByteArray (QByteArray)
descriptionReview ((QString))
monthReview (QString)
dayReview (QString)
yearReview (QString)
historyReview (QString)
ageReview (QString)
notesReview (QString)
colorReview (QString)
materialReview (QString)
SignedbyReview (QString)
whatReview (QString) -
@VRonin
In Review the data added to the database and I want to update the table in MainWindow using the record just added to the db. -
@gabor53 Sorry, I did not explained myself. Review is a Dialog, where do you make this dialog appear?
-
Now you lost me completely.
typedef Review Additem;?? I guess not becausevoid Review::on_pushButton_Fix_clicked() { Additem *mAdditem = new Additem(this);@VRonin
Originally, after main.cpp MainWindow.cpp loads. MainWindow has the tableview that displays 4 columns from the database. The user can call Additem.cpp from MainWindow to add more items to the db. After data entry Review.cpp is called where the user can review the data he/she entered. Here there are two choices: either click PushButton_fix to correct errors (this takes back to Additem.cpp) or if all correct you can click Add_to_Db and the item is added to the db. After adding RecAdded signal emitted to add the new record to the tableview in MainWindow. I hope this helps. -

Ok, your design is "borderline". Could you please post additem.h and additem.cpp too please?
-
Unrelated to main topic but I just took a glimpse at your code:
QString date = QDate::currentDate().toString (); list = date.split (QRegExp("\\s+")); int size = list.size (); QString sYear = list.at (size-1); yeark = sYear.toInt ();do you mean?
yeark = QDate::currentDate().year(); -
Hai....
you just try by this line of code instead of your connect statement
connect(this,&Review::RecAdded,this,&Review::updateTable,Qt::UniqueConnection);
It may help you..