Results 1 to 6 of 6

Thread: how to use macros in Qtwidget

  1. #1
    Join Date
    Nov 2014
    Location
    Chennai
    Posts
    160
    Thanks
    65
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default how to use macros in Qtwidget

    am having coding below
    QString configpath("/home/ishwarya/display_images");
    i should not use this path directly in coding , i have to give in macros.
    can any one please guide to me to do macros.
    Thanks in Advance

  2. #2
    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: how to use macros in Qtwidget

    Looks like a school question on C++ programming (that has nothing at all to do with Qt). Perhaps you should consult your text books or a basic C or C++ tutorial?

  3. The following user says thank you to ChrisW67 for this useful post:

    iswaryasenthilkumar (8th January 2015)

  4. #3
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: how to use macros in Qtwidget

    Quote Originally Posted by iswaryasenthilkumar View Post
    am having coding below
    QString configpath("/home/ishwarya/display_images");
    i should not use this path directly in coding , i have to give in macros.
    can any one please guide to me to do macros.
    Thanks in Advance
    I suspect what you're looking for is something like this in a header file:
    Qt Code:
    1. #define CONFIG_PATH "/home/ishwarya/display_images"
    To copy to clipboard, switch view to plain text mode 

    and then in your cpp file:
    Qt Code:
    1. QString configpath(CONFIG_PATH);
    To copy to clipboard, switch view to plain text mode 
    This approach would allow you to reference the config path anywhere in your code and if you need to change it, you only need to change the define statement in the header file. That said, it really sounds like your config path should either be specified via user input or specified programattically rather than hard coded. There certainly is not a "/home/ishwarya/display_images" folder on anyone else's system.

    Good luck.

  5. The following user says thank you to jefftee for this useful post:

    iswaryasenthilkumar (4th February 2015)

  6. #4
    Join Date
    Nov 2014
    Location
    Chennai
    Posts
    160
    Thanks
    65
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: how to use macros in Qtwidget

    i have to define text file in #define.
    i defined
    #define "/home/ishwarya/display_images/DI_config.txt"
    bt this line shows an error ,,
    can any one give suggestion for this
    Thanks in advance
    Quote Originally Posted by jthomps View Post
    I suspect what you're looking for is something like this in a header file:
    Qt Code:
    1. #define CONFIG_PATH "/home/ishwarya/display_images"
    To copy to clipboard, switch view to plain text mode 

    and then in your cpp file:
    Qt Code:
    1. QString configpath(CONFIG_PATH);
    To copy to clipboard, switch view to plain text mode 
    This approach would allow you to reference the config path anywhere in your code and if you need to change it, you only need to change the define statement in the header file. That said, it really sounds like your config path should either be specified via user input or specified programattically rather than hard coded. There certainly is not a "/home/ishwarya/display_images" folder on anyone else's system.

    Good luck.

  7. #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: how to use macros in Qtwidget

    This is not C++ kindergarden and your question has no relation to Qt.

    I can only say the define statement you posted makes no sense syntax-wise.
    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. #6
    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: how to use macros in Qtwidget

    ... And you even quoted the text that shows exactly how it should be used in this thread

Similar Threads

  1. Embedding MacOS application in QtWidget
    By brainTech in forum Newbie
    Replies: 0
    Last Post: 3rd January 2013, 05:46
  2. Replies: 5
    Last Post: 4th May 2011, 14:37
  3. igstk::QTWidget display problem.
    By Ashwath in forum Newbie
    Replies: 0
    Last Post: 4th March 2011, 07:51
  4. Replies: 4
    Last Post: 4th December 2010, 01:52
  5. QtWidget in Overlay Planes on Windows OpenGL
    By IVTdeveloper in forum Qt Programming
    Replies: 2
    Last Post: 20th August 2008, 11:00

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.