Results 1 to 15 of 15

Thread: update grid of pixmap labels based on 2d char arrray value

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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: update grid of pixmap labels based on 2d char arrray value

    Quote Originally Posted by wuts.the.martyr View Post
    Now I am trying to make a for loop situation where i make a QString equal the name of a label I would like to change, but am having a problem trying to typecaste it to be that label I want.
    You cannot rewrite C++ code at run time, which seems to be what you are expecting to happen. You need to abandon this line of thinking. You don't have 100 labels with individual names any more and you already have a way to change the pixmap on the anonymous label at a given row and column in the layout (setCellPixmap() in my example). What is the new problem you are trying to solve?

  2. #2
    Join Date
    Dec 2011
    Posts
    10
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: update grid of pixmap labels based on 2d char arrray value

    so i can't use the contents of the QString to reference a QLabel by name? that's all I am trying to do. I understand you can't rewrite. I would just like to bend the rules a bit, and use the string that i conjure up each run through to grab the appropriate label and swap the image. I will attempt to go back to what you had, now that I know how to get the png files I require, if that's what it takes, I just wanted to do something simple albeit time consuming to code since I am running out of time. I am not trying to be hard headed here either, I just am having a hard time getting what I ultimately want, that I currently have minus the updating of game tiles. With what you have given me, I will need to figure out how to place it in my existing widget container. That is why I havent gone that route. I know you have already done so much, but i can only do fairly simple things using the Designer and slots/signals. Would you still be willing to at the very least help me get the game board we made placed inside my page widget. as it lies right now it breaks my game.
    Last edited by wuts.the.martyr; 6th December 2011 at 01:57.

  3. #3
    Join Date
    Dec 2011
    Posts
    10
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: update grid of pixmap labels based on 2d char arrray value

    Sorry again, its just hard to give up on something I spent a lot of time on, I've gotten to work finally even, but honestly its a terrible method and I have to write a bunch of code to differentiate between the QWidget class and QMainwindow back and forth since the mainwindow takes on the characteristics of the QWidget class. Whilst I have managed to get your code to resize a bit, I would still rather have it take on the properties of my current QGridLayout I created using Designer, or even just place the pixmaps in there, but i see the later being a problem possibly? any ideas?

  4. #4
    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: update grid of pixmap labels based on 2d char arrray value

    You can build the game panel with Designer and still use the general method for finding the label at [r,c] in a grid layout. See the attached complete Designer built example (3x3 but you get the idea). I have put a timed, random event in the main window so you can see stuff changing on the two game panels. It doesn't matter what you call the labels, and you don't have to try to find them by name.
    Attached Files Attached Files

Similar Threads

  1. Creating a pixmap from unsigned char*
    By winder in forum Qt Programming
    Replies: 9
    Last Post: 6th July 2021, 13:56
  2. Replies: 8
    Last Post: 5th May 2021, 16:41
  3. Replies: 1
    Last Post: 19th April 2011, 11:17
  4. Replies: 0
    Last Post: 14th October 2010, 18:45
  5. Rapid Update of Pixmap
    By dbrmik in forum Qt Programming
    Replies: 5
    Last Post: 23rd April 2009, 10:49

Tags for this Thread

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.