Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Creating a keypress signal from application button
QtWS25 Last Chance

Creating a keypress signal from application button

Scheduled Pinned Locked Moved General and Desktop
34 Posts 4 Posters 36.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vsorokin
    wrote on last edited by
    #19
    1. didn't you forget implement destructor body?
    2. Ok, please, show code line where you create instance of MyTableView class or line where you use this instance as parameter of method

    --
    Vasiliy

    1 Reply Last reply
    0
    • L Offline
      L Offline
      ludde
      wrote on last edited by
      #20

      I think the build error probably has nothing to do with the definition of your MyTableView class, but rather how you use it. Maybe you are using an assignment with a MyTableView object somewhere, where you should really be assigning a pointer?

      1 Reply Last reply
      0
      • M Offline
        M Offline
        maxmotor
        wrote on last edited by
        #21

        My setup.h file:

        @#include "ui_setup.h"
        #include "parent_ui.h"
        #include "mytableview.h"

        class Setup: public Parent_ui {
        Q_OBJECT

        public:
        Setup(QWidget *parent = 0);
        ~Setup();
        MyTableView myTableViewInstance;

        private:
        Ui::SetupClass ui;
        void createActions();

        private slots:
        void up();
        void down();
        void enter();
        void back();

        };@

        My setup.cpp file:

        @#include "setup.h"
        #include <QListWidget>

        Setup::Setup(QWidget *parent) :
        Parent_ui(parent) {

        ui.setupUi(this);
        Parent_ui::ui.headerLabel->setText("SETUP");

        myTableViewInstance = new MyTableView();
        }

        Setup::~Setup() {

        }
        @

        The error I get when calling "myTableViewInstance = new MyTableView();":

        'QWidget' is an inaccessible base of 'MyTableView'

        1 Reply Last reply
        0
        • L Offline
          L Offline
          ludde
          wrote on last edited by
          #22

          It's because you are assigning a pointer to an object. myTableViewInstance has to be a pointer.

          1 Reply Last reply
          0
          • V Offline
            V Offline
            vsorokin
            wrote on last edited by
            #23

            ludde are right:
            in your setup.h file
            @
            ...
            MyTableView *myTableViewInstance;
            ...
            @

            --
            Vasiliy

            1 Reply Last reply
            0
            • M Offline
              M Offline
              maxmotor
              wrote on last edited by
              #24

              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?

              1 Reply Last reply
              0
              • V Offline
                V Offline
                vsorokin
                wrote on last edited by
                #25

                @ connect(ui.buttonTwo, SIGNAL(clicked()), myTableViewInstance, SLOT(key_down()));
                @

                --
                Vasiliy

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  maxmotor
                  wrote on last edited by
                  #26

                  I get this error: 'QObject' is an inaccessible base of 'MyTableView'

                  1 Reply Last reply
                  0
                  • V Offline
                    V Offline
                    vsorokin
                    wrote on last edited by
                    #27

                    Please show MyTableView constructor implementation

                    --
                    Vasiliy

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      maxmotor
                      wrote on last edited by
                      #28

                      It is empty :/

                      @MyTableView::MyTableView(QWidget* parent) : QTableView(parent){

                      }@

                      1 Reply Last reply
                      0
                      • V Offline
                        V Offline
                        vsorokin
                        wrote on last edited by
                        #29

                        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 :)

                        --
                        Vasiliy

                        1 Reply Last reply
                        0
                        • M Offline
                          M Offline
                          maxmotor
                          wrote on last edited by
                          #30

                          I have sent you a link :)

                          1 Reply Last reply
                          0
                          • V Offline
                            V Offline
                            vsorokin
                            wrote on last edited by
                            #31

                            Oh... many points:

                            1. In your sources
                              @class MyTableView: private QTableView {@

                            although, in example above you wrote:
                            @class MyTableView: public QTableView {@

                            1. You don't needed MyTableView, you already have QTabletWidget on form
                            2. You don't needed inheritance in this case.
                            3. 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);

                            }@

                            --
                            Vasiliy

                            1 Reply Last reply
                            0
                            • M Offline
                              M Offline
                              maxmotor
                              wrote on last edited by
                              #32

                              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!

                              1 Reply Last reply
                              0
                              • M Offline
                                M Offline
                                maxmotor
                                wrote on last edited by
                                #33

                                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!

                                1 Reply Last reply
                                0
                                • V Offline
                                  V Offline
                                  vsorokin
                                  wrote on last edited by
                                  #34

                                  [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

                                  --
                                  Vasiliy

                                  1 Reply Last reply
                                  0

                                  • Login

                                  • Login or register to search.
                                  • First post
                                    Last post
                                  0
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular
                                  • Users
                                  • Groups
                                  • Search
                                  • Get Qt Extensions
                                  • Unsolved