Creating a keypress signal from application button
-
wrote on 15 Sept 2011, 11:57 last edited by
It's because you are assigning a pointer to an object. myTableViewInstance has to be a pointer.
-
wrote on 15 Sept 2011, 12:08 last edited by
ludde are right:
in your setup.h file
@
...
MyTableView *myTableViewInstance;
...
@ -
wrote on 15 Sept 2011, 12:24 last edited by
That was it, thank you :)
Okay to get back to the subject (Which I slowly turned away from introducing other challenges :) ).
I have made a slot in MyTableView:
@void MyTableView::key_down(){
QTableView::moveCursor(QAbstractItemView::MoveDown, Qt::NoModifier);
}@This is then used in my setup.cpp file:
@void Setup::createActions() {
QObject::connect(ui.buttonTwo, SIGNAL(clicked()), this, SLOT(myTableViewInstance->key_down()));
}@
This has no effect on my QTableWidget though. But I guess it's me and my coding which is faulty again. Can you see from my code snippets what I'm doing wrong?
-
wrote on 15 Sept 2011, 12:41 last edited by
@ connect(ui.buttonTwo, SIGNAL(clicked()), myTableViewInstance, SLOT(key_down()));
@ -
wrote on 15 Sept 2011, 12:46 last edited by
I get this error: 'QObject' is an inaccessible base of 'MyTableView'
-
wrote on 15 Sept 2011, 12:55 last edited by
Please show MyTableView constructor implementation
-
wrote on 15 Sept 2011, 12:59 last edited by
It is empty :/
@MyTableView::MyTableView(QWidget* parent) : QTableView(parent){
}@
-
wrote on 15 Sept 2011, 13:07 last edited by
oh... I haven't more ideas :)
Try change
@#include "qtableview.h"@
to@#include <QTableView>@
if nothing changes, just put all your sources to file hosting and get me link :)
-
wrote on 15 Sept 2011, 15:39 last edited by
I have sent you a link :)
-
wrote on 15 Sept 2011, 17:31 last edited by
Oh... many points:
- In your sources
@class MyTableView: private QTableView {@
although, in example above you wrote:
@class MyTableView: public QTableView {@- You don't needed MyTableView, you already have QTabletWidget on form
- You don't needed inheritance in this case.
- In setup.cpp
I rewrite some things:
It's for local slot, because MyTableView not needed anymore
@connect(ui.buttonTwo, SIGNAL(clicked()), this, SLOT(down()));@
in slot, as example, you can add any checks and other logic to their:
@void Setup::down() {
Parent_ui::ui.tableWidget->selectRow(Parent_ui::ui.tableWidget->currentRow() + 1);
}@same for up slot:
@void Setup::up() {
Parent_ui::ui.tableWidget->selectRow(Parent_ui::ui.tableWidget->currentRow() -1);}@
- In your sources
-
wrote on 15 Sept 2011, 19:20 last edited by
Vass you are very kind!
I will have a look at this the first thing in the morning.
Especially you and ludde have been a big help so far dealing with my lack of Qt/C++ skills.
Thank you guys!
-
wrote on 16 Sept 2011, 09:41 last edited by
I just wanted to tell you that my code is now working as intended! - Thanks to you!
I'm very impressed of the willingness to help out on this forum. And the fast response was superb.
I'm almost positive that we will talk again! ;)
Thank you so much for your time!
-
wrote on 16 Sept 2011, 09:48 last edited by
[quote author="maxmotor" date="1316166090"]I just wanted to tell you that my code is now working as intended![/quote]
Glad to hear! :)
However, I highly recommend you learning C++ - it just save your time in future
31/34