Results 1 to 5 of 5

Thread: Managing table of labels

  1. #1
    Join Date
    Oct 2012
    Location
    Warsaw,Poland
    Posts
    17
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Managing table of labels

    Hi!

    Let's imagine an example: I want to have 8x8 labels in *.ui file for displaying figures in chess. Now, when I use designer and add labels, they have names like: label, label_2, label_3 and so on. And I want to have a function, which parameters are x and y and in this function I want to change label image of corresponding field. How can I do this? 64 conditions?

    Qt Code:
    1. void changeLabelOf(int x, int y)
    2. {
    3. if (x==0 && y==0) ui->label->setPixmap(....);
    4. if (x==1 && y==0) ui->label_2->setPixmap(....);
    5. if (x==2 && y==0) ui->label_3->setPixmap(....);
    6. .
    7. .
    8. .
    9. }
    To copy to clipboard, switch view to plain text mode 

    Is there something like macro to do this? Someone know how can I deal with this situation?

  2. The following user says thank you to danioto for this useful post:


  3. #2
    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: Managing table of labels

    Implementing this with Designer like that is a really bad idea. You'd better hand code it and put all the labels in an array/list.
    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.


  4. The following user says thank you to wysota for this useful post:


  5. #3
    Join Date
    Oct 2012
    Location
    Warsaw,Poland
    Posts
    17
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Managing table of labels

    Yes, I know it's a way to do this, but it's really inconvenient and pretty much work to do. Doing this with designer I can quickly create good looking and properly resizing widgets. Is there nothing I can do at the designer level?

  6. The following user says thank you to danioto for this useful post:


  7. #4
    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: Managing table of labels

    Quote Originally Posted by danioto View Post
    Yes, I know it's a way to do this, but it's really inconvenient and pretty much work to do. Doing this with designer I can quickly create good looking and properly resizing widgets. Is there nothing I can do at the designer level?
    Using Designer for this particular layout is much more work than hand-coding it. After all it is just 6-7 lines of code.
    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.


  8. The following user says thank you to wysota for this useful post:


  9. #5
    Join Date
    Oct 2012
    Location
    Warsaw,Poland
    Posts
    17
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Managing table of labels

    Ok! I'll do it by hand. Thanks

    Pozdro!
    Daniel

  10. The following user says thank you to danioto for this useful post:


Similar Threads

  1. Replies: 3
    Last Post: 19th April 2013, 12:04
  2. Managing Widget (by mouse)
    By peace_comp in forum Newbie
    Replies: 1
    Last Post: 30th May 2011, 16:57
  3. Hi All, Problem in managing events
    By siva prasanna in forum Qt Programming
    Replies: 1
    Last Post: 2nd November 2009, 15:54
  4. managing workerthreads
    By darksaga in forum Qt Programming
    Replies: 4
    Last Post: 20th August 2007, 18:26

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.