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. How to connect a signal of a widget, which is created latter in the program?
Forum Updated to NodeBB v4.3 + New Features

How to connect a signal of a widget, which is created latter in the program?

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 2.4k Views 1 Watching
  • 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.
  • A Offline
    A Offline
    aurora
    wrote on last edited by
    #1

    I have QTableWidget...I declared it in class declaration...
    @.QTableWidget *filesTable;
    @

    I am creating this QTable in some function of that class
    ..after clicking on a button....(multiple files created if multiple times clicked.)

    Now i want to get "customContextMenuRequested" of that table.....
    @
    connect(Table,SIGNAL(customContextMenuRequested(const QPoint &)),this,SLOT(ProvideContextMenu(const QPoint &)));
    @
    in constructor, my program crashes as i not yet allocated memory for that table.....

    If i declare table i.e
    @
    Table= new QTableWidget(this);
    @
    in constructor i create multiple tables....

    So what should i do to solve this problem?

    1 Reply Last reply
    0
    • ? This user is from outside of this forum
      ? This user is from outside of this forum
      Guest
      wrote on last edited by
      #2

      Hi,

       you can clear the table before adding data in to the table.i hope it will help u
      
      1 Reply Last reply
      0
      • F Offline
        F Offline
        fluca1978
        wrote on last edited by
        #3

        When you create the table add the signal just after. Or create a wrapper method that creates and connects the table. You are not constrained to connect signals only from within an object, you can connect at any time and from anywhere if they are public.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          You can only create connections at a place in your code where:

          Both objects exist

          You can access pointers to both objects

          That means that you simply cannot create a connection to an object that has not been created yet. Why don't you create the connection at the place where you created the table?

          1 Reply Last reply
          0
          • A Offline
            A Offline
            aurora
            wrote on last edited by
            #5

            [quote author="cdeepak" date="1329374871"]Hi,

             you can clear the table before adding data in to the table.i hope it will help u[/quote]
            

            No i want to display all the tables.....multiple tables are shown in tab widget..

            1 Reply Last reply
            0
            • A Offline
              A Offline
              aurora
              wrote on last edited by
              #6

              ok thank u...

              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