Results 1 to 2 of 2

Thread: Duplicating and renaming a project breaks code

  1. #1
    Join Date
    Apr 2014
    Posts
    59
    Thanks
    7
    Qt products
    Qt5
    Platforms
    Windows

    Default Duplicating and renaming a project breaks code

    <edit>I figured this out while I was composing this post, but figured I would post anyway, in case it is useful for someone else. The problem was that my kit was configured different, from the one the original project used. The original warning was somewhat correct, but instead of the compiler being wrong it was the Qt version. I had 5.2.1 selected instead of 5.8.0. </edit>

    I need to re-purpose a project and I thought it would be easier to just strip out what I do not need than to rewrite what I do need. I copied the project folder to a new directory and renamed the project folder. I then renamed the .pro file and the target, then deleted the .pro.user file. I got a warning when I opened it Creator:
    Qt Code:
    1. :-1: warning: "E:\QtA\Tools\mingw482_32\bin\g++.exe" is used by qmake, but "E:\QtA\Tools\mingw482_32\bin\g++.exe" is configured in the kit.
    2. Please update your kit or choose a mkspec for qmake that matches your target environment better.
    To copy to clipboard, switch view to plain text mode 
    which I ignored since it did not make sense. Building the project was a different story. I eliminated half the warnings by copying the database folder, and others, to the build folder. I am not really concerned with the rest of the warnings, and the error is in a function that will get stripped, but I do not understand why warning free code suddenly has 30 warnings and an error preventing it from building. The error is:
    Qt Code:
    1. error: invalid conversion from 'char' to 'const char*' [-fpermissive]
    2. if(QStringRef(&link, 0, 1) == '/')
    3. ^
    To copy to clipboard, switch view to plain text mode 
    referenced from:
    Qt Code:
    1. E:\Qt\Qt5.2.1\5.2.1\mingw48_32\include\QtCore\qstring.h:1345: error: initializing argument 1 of 'bool QStringRef::operator==(const char*) const' [-fpermissive]
    2. inline QT_ASCII_CAST_WARN bool QStringRef::operator==(const char *s) const
    To copy to clipboard, switch view to plain text mode 
    The offending function:
    Qt Code:
    1. void MainWindow::on_dataView_activated(const QModelIndex &index)
    2. {
    3. QString header = model->headerData(index.column(),
    4. Qt::Horizontal).toString();
    5.  
    6. if(header == "Datasheet")
    7. {
    8. QString link = index.data(Qt::UserRole).toString();
    9.  
    10. if(QStringRef(&link, 0, 4) == "http")
    11. QDesktopServices::openUrl(link);
    12. else if(link == "")
    13. return;
    14. else
    15. {
    16. if(QStringRef(&link, 0, 1) == '/')
    17. link.prepend(QDir::current().currentPath());
    18.  
    19. QDesktopServices::openUrl("file:///" + link);
    20. }
    21. }
    22. }
    To copy to clipboard, switch view to plain text mode 

    Changing '/' to "/" fixed the error, but an identical one popped up in the model, which does not surprise me since it is basically the same code.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Duplicating and renaming a project breaks code

    Thanks for sharing!
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. Renaming my .pro project file;
    By mut in forum Newbie
    Replies: 1
    Last Post: 17th June 2014, 02:35
  2. Replies: 3
    Last Post: 25th October 2013, 11:39
  3. QT Project source code
    By darpan in forum Qt Programming
    Replies: 3
    Last Post: 27th December 2012, 17:16
  4. Replies: 2
    Last Post: 13th June 2011, 16:29
  5. code for new project
    By rk0747 in forum Qt Programming
    Replies: 10
    Last Post: 18th February 2010, 21:44

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.