This forum has been archived. All content is frozen. Please use KDE Discuss instead.

[SOLVED] Qt: Access GUI from another class

Tags: None
(comma "," separated)
User avatar
mensch
Registered Member
Posts
178
Karma
0
OS
I'm not sure which ui file to refer to. Mainwindow has a ui file, but dataModel is just a class containing functions without GUI elements. updateProjectData() is a function belonging to the dataModel class, but I can't get access to that function because I think I'm not passing the right pointer. Hence the error regarding QObject::updateProjectData(QTreeWidgetItem*) not existing.
I think it should be dataModel::updateProjectData(QTreeWidgetItem*) instead of QObject::updateProjectData(QTreeWidgetItem*).

Last edited by mensch on Wed Apr 15, 2009 9:49 pm, edited 1 time in total.


I have forced myself to contradict myself in order to avoid conforming to my own taste. Marcel Duchamp
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
Can you please post the full signature for the dataModel::updateProjectData function? Also, make sure the slot is declared public, by default they are private.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
mensch
Registered Member
Posts
178
Karma
0
OS
Of course, datamodel.cpp
Code: Select all
void dataModel::updateProjectData(QTreeWidgetItem* item)
 {
 }

It's declared as a public slot in datamodel.h:
Code: Select all
class dataModel : public QObject
{

  public:
    dataModel(QObject* parent, MainWindow* mainWindow);
 
  public slots:
    void updateProjectData(QTreeWidgetItem* item);
};


I have forced myself to contradict myself in order to avoid conforming to my own taste. Marcel Duchamp
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
Can you please add Q_OBJECT above "public:" in your header? Otherwise the Meta Object Compiler won't be run on your files.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
mensch
Registered Member
Posts
178
Karma
0
OS
That makes sense, but I get two nasty errors when compiling:
Code: Select all
Tool:0: "dataModel::staticMetaObject", referenced from:
Tool:0: symbol(s) not found
Tool:0: __ZTV10dataKernel$non_lazy_ptr in datamodel.o


Code: Select all
Tool:0: "vtable for dataModel", referenced from:
Tool:0: __ZN10dataModel16staticMetaObjectE$non_lazy_ptr in datamodel.o

Last edited by mensch on Thu Apr 16, 2009 5:19 am, edited 1 time in total.


I have forced myself to contradict myself in order to avoid conforming to my own taste. Marcel Duchamp
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
What are you using for your build system?
- If it is QMake, you may need to re run it ( qmake ) to regenerate the Makefile.
- If it is CMake, could you please post CMakeLists.txt


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
mensch
Registered Member
Posts
178
Karma
0
OS
I'm developing this in Xcode on OS X, so my guess I'm using neither at the moment. I ran qmake from the commandline which sorted things out. Everything builds now! Warnings about slots have also vanished, all because I didn't include the Q_OBJECT macro... :-$

Thanks again!


I have forced myself to contradict myself in order to avoid conforming to my own taste. Marcel Duchamp


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot]