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. generic variable type?
Forum Update on Monday, May 27th 2025

generic variable type?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 949 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.
  • H Offline
    H Offline
    harry
    wrote on 27 Sept 2015, 00:51 last edited by
    #1

    hi.
    is there a variable type that can hold a pointer to any type of oblect, like id in OSX?

    i want to add a myButton (subclass of QWidget) to an instane of another subclass of QWidget, and they need to communicate. problem is that i can't predict what type of object myButton will be added to. could be a screen or a buttonBar or some other subclass of QWidget i haven't even thought of yet. so how can i make sure they can communicate? communication is required so that the screen can tell the button what size, shape and color the button should be and what text it should display.

    1 Reply Last reply
    0
    • H Offline
      H Offline
      Hamed
      wrote on 27 Sept 2015, 07:49 last edited by
      #2

      Hi,
      I don't know if I got you right, but I think void* pointer will do it for you.

      HamedBabaeyan@yahoo.com
      for more interesting stuff

      1 Reply Last reply
      0
      • L Offline
        L Offline
        LuGRU
        wrote on 27 Sept 2015, 12:13 last edited by
        #3

        If I do understand correctly then QWidget* is enough.
        All Ui drawable elements are QWidget base and If You are looking only for base widget functionality like size, with is accessible in QWidget, then that's fine, if You want custom interaction, i.e. myButton overwrites size and defined completely new behavior or there are custom signals etc., then on that QWidget pointer do cast to defined type and then just work with that object.

        1 Reply Last reply
        0

        1/3

        27 Sept 2015, 00:51

        • Login

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