Results 1 to 8 of 8

Thread: Unique Id of Qwidget

  1. #1
    Join Date
    Aug 2011
    Posts
    7
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Unique Id of Qwidget

    I want to do QHash which will be used key (some widget id)
    how can I get a certain individual Id of qwidget for use it as a unique key?
    objectname can not be used because QHash will contain widgets from different classes,
    meaning they can be the widgets with the same name....

  2. #2
    Join Date
    Sep 2011
    Posts
    3
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Symbian S60 Maemo/MeeGo

    Default Re: Unique Id of Qwidget

    How about the pointer address (cast to an appropriately-sized integer, i.e. qint32 or qint64 depending on your platform)? For widgets within a process, this will be unique for each instance.

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Unique Id of Qwidget

    Quote Originally Posted by alex1 View Post
    objectname can not be used because QHash will contain widgets from different classes,
    meaning they can be the widgets with the same name....
    Only if you program it that way. Having each class set its object name to a UUID or QString("ClassName%1).arg(staticSequenceVariable++ ) in its constructor would be another approach.

  4. #4
    Join Date
    Aug 2011
    Posts
    7
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Question Re: Unique Id of Qwidget

    Thanks very much.

    But, what can I do to not be dependent on the platform?
    QVariant do not want to use,
    ifndef / endef also do not want to use.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Unique Id of Qwidget

    I'd go for pointers or a unique number generator.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Aug 2011
    Posts
    7
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Unique Id of Qwidget

    Thanks,
    But a unique number will not work because key must be part of QWidget
    So I need to use :{ ,
    have other ideas?

  7. #7
    Join Date
    Oct 2010
    Location
    Berlin, Germany
    Posts
    358
    Thanks
    18
    Thanked 68 Times in 66 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Unique Id of Qwidget

    then you have to use the pointer adress.

    btw, why must the key be part of QWidget?

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Unique Id of Qwidget

    Quote Originally Posted by alex1 View Post
    Thanks,
    But a unique number will not work because key must be part of QWidget
    I don't see your point. It works quite fine for Qt Creator so I don't see why wouldn't it work for you.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Dbus -Unique sender id?
    By tyrnikeisari in forum Qt Programming
    Replies: 1
    Last Post: 8th May 2011, 23:09
  2. How to get a unique random number on mac?
    By punitk in forum Qt Programming
    Replies: 0
    Last Post: 12th October 2010, 16:59
  3. Unique ID for a PC to use for Key Validation
    By nbkhwjm in forum Qt Programming
    Replies: 1
    Last Post: 9th April 2008, 23:13
  4. The unique key
    By igor.alexandrov in forum Qt Programming
    Replies: 9
    Last Post: 26th January 2008, 00:27
  5. ContextMenu Very unique GUI.
    By VireX in forum Qt Programming
    Replies: 14
    Last Post: 15th April 2007, 08:45

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.