Results 1 to 16 of 16

Thread: Working with QObject

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2006
    Posts
    426
    Thanks
    8
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Working with QObject

    Quote Originally Posted by been_1990 View Post
    I guess I just need to know how to to that in a for() loop. And what exactly is QObject, is it a general-purpose object for OOP? Does addChild() create a new object and can I acess it and change-add its value? Can I give the child a name that can be acessed anywhere? Not much of a problem, just searching for guidance.
    I actually want to make several boxes across the screen and give each one several values, such as heigth, width, name, image and be able to receive events from them, ex: click , doubleclick , hover, etc.
    Your questions beat our guru

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Working with QObject

    I actually want to make several boxes across the screen and give each one several values, such as heigth, width, name, image and be able to receive events from them, ex: click , doubleclick , hover, etc.
    May be you can go for Graphics View framework ? your boxes will be graphics items..

    or you can have several QWidgets on the screen, so u can get all hover, click etc events..
    hope i understood ur prob right

  3. #3
    Join Date
    Oct 2008
    Posts
    306
    Thanks
    6
    Thanked 9 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Working with QObject

    Quote Originally Posted by aamer4yu View Post
    May be you can go for Graphics View framework ? your boxes will be graphics items..

    or you can have several QWidgets on the screen, so u can get all hover, click etc events..
    hope i understood ur prob right
    But thats exactly what I'll do. I'll read the number of .xml files in a directory. Then for each .xml file I'll load a QIcon data saved in a node, read other info from other nodes. Then put the QIcon pixmap in a QGraphicsView thats already set up. I need to somehow tie all the .xml nodes together so when I click on, let's say, QGraphicsView.firstChild() I can acess the other info that would be loaded into the same object as the graphic I just clicked. I hope I explained myself clearly. I've already done this using Actionscript 3.0 in Flash, but using QT beats me.
    Last edited by been_1990; 16th June 2009 at 18:16.

  4. #4
    Join Date
    Oct 2008
    Posts
    306
    Thanks
    6
    Thanked 9 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Talking Re: Working with QObject

    I guess I started with my left foot in this thread... I started asking something that wont take me to where I want to go. This is what I want to know:

    Whats the best way to load a pixmap from a data file? Using QGraphicsView? Or making a new widget for each pixmap? I want to be able to grab events that happen to the object holding the pixmap.

    I'm really sorry for the wrong explanation of what I needed, one day I'll get it rigth from the beggining...

  5. #5
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Working with QObject

    Whats the best way to load a pixmap from a data file?
    QPixmap::load or QPixmap::loadFromData
    Or making a new widget for each pixmap? I want to be able to grab events that happen to the object holding the pixmap.
    That depends on what kind of events you want to capture..and what you want to do on those events.
    For basic mouse clicks and double clicks, use QLabel will be good enough. You can you QLabel in grid layout and show multiple pics..
    If you want some anitmation, go for graphics view. You can refer Embedded dialog demo in Qt Demo (since 4.5) . Instead of dialog, you can have your widget or graphics item.

    Can refer more if you tell what actions you want to perform on events on the pixmap.

  6. #6
    Join Date
    Oct 2008
    Posts
    306
    Thanks
    6
    Thanked 9 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Post Re: Working with QObject

    Qt Code:
    1. Functionality needed:
    2.  
    3. Click/Double-Click ;
    4. Click&Drag;
    5. On Hover animation;
    6. Speed;
    7. Left-Click menu;
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: Working with QObject

    Go for QGraphicsView and friends.
    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. #8
    Join Date
    Oct 2008
    Posts
    306
    Thanks
    6
    Thanked 9 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Working with QObject

    Ok, I'll use QGraphicsView. Now back to my first question, how can I group some data? In a array? Or is there something more "QT"? Ex:

    Qt Code:
    1. arrayMain{
    2. obj1{"myname", 01001010-myData, myPlaceInTheWorld};
    3. obj2{"myname", 01401010-myData, myPlaceInTheWorld};
    4. obj3{"myname", 01021010-myData, myPlaceInTheWorld};
    5. obj4{"myname", 01042210-myData, myPlaceInTheWorld};
    6. }
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: Working with QObject

    Group it the way you want... I don't really understand the problem. Your data has some structure, so represent that structure using classes and instances of them.
    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. QObject signal/slot not working
    By Msnforum in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2009, 22:50
  2. py2app-deployed PyQt app -- throws QObject threading error
    By tory108 in forum Installation and Deployment
    Replies: 4
    Last Post: 20th January 2009, 20:16
  3. QResource Stopped Working
    By JPNaude in forum Qt Programming
    Replies: 0
    Last Post: 22nd October 2008, 12:26
  4. QObject and copy Constructors
    By December in forum Qt Programming
    Replies: 5
    Last Post: 17th July 2008, 16:14
  5. GUI thread and Working thread comunication
    By FasTTo in forum Qt Programming
    Replies: 2
    Last Post: 13th September 2007, 15:31

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
  •  
Qt is a trademark of The Qt Company.