LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-30-2015, 12:05 PM   #1
DrDwayne
Member
 
Registered: May 2010
Location: Wichita
Distribution: Ubuntu Debian
Posts: 155

Rep: Reputation: 4
QT creator


Hello folks,

I am trying to learn this linux and its C/C++. I have downloaded QT creator as an IDE. . ..but still having problems.

I only need a little kick in the fanny, and things will come together.
I have 35 years programming experience in C and C++, using Borland's and Embacardero compilers. ..from Turbo c/c++ to their latest RAD Studio.

What I did, was used the QT creator, and put 2 push buttons and 1 line edit field on the form.

The only thing I want to do, is to push one of the buttons, and allow that button to place something in the editline field. It took me a while to find out that "Go to Slot" was part of what I was looking for. (smile).

This is what I have so far:

Quote:
void MainWindow:n_pushButton_clicked()
{
char Favor[10]="Testing2";
// strcpy((char*) ui->lineEdit,(char*)"Testing");
// strcpy((char*)ui->lineEdit,Favor);
// strcpy(&ui->lineEdit,Favor);
// strcpy(ui->lineEdit->text(),"testing");
ui->lineEdit->text()="testing";
// ui->lineEdit->text()=Favor;
ui->lineEdit->repaint();

return;
}
the comment lines are things I have tried, but have no worked. And when I finally get to to compile, it does not show my data in the field.

Could someone please shove me in the correct direction to accomplish this?
Do I use malloc?

Just don't know where to go on this one. . thanks in advance.
 
Old 11-30-2015, 12:52 PM   #2
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,225

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
Code:
ui->lineEdit->setText("testing");
Turbo C++ is what I learned C++ on, btw. Wasn't it and its manual great?

Last edited by dugan; 11-30-2015 at 01:22 PM.
 
2 members found this post helpful.
Old 11-30-2015, 01:44 PM   #3
DrDwayne
Member
 
Registered: May 2010
Location: Wichita
Distribution: Ubuntu Debian
Posts: 155

Original Poster
Rep: Reputation: 4
Hello Dugan,

Heck yes, Turbo C/C++ when it came out, was a wonderful DOS compiler. . . Amazing that it fit on a floppy disk or two. I have been with Borland since then. I was also Beta Tester for Teseract that used this same compiler for their stuff.

I wish I still had my copy of C/C++. . .I thought I saved it, but I guess I didn't get all of it. It had such a primitive debugger, but it worked surprisingly well. I know I have everything of Borlands AFTER Turbo C/C++ (I think it was Borland Turbo 3 that came out with a new fancy IDE. then when all the way up to T/C version 5 before it switched to Borland C builder.

My main BCB is version 5. I use RAD XE8 for customers, I haven't purchased RAD XE10. I doubt if I will. I am about to retire, and don't think it is worth the $$$$ dollar upgrade. By the way Embacadereo just got bought out about 1 month ago. . .I am not sure how long the XE's are going to last.

Anyhow thank you for your help. . .worked like a champ. . .I just have to get used to the idiosyncrasies between the different compilers. I would like to transfer a few of my programs to Linux. They run well in Wine, and my older ones will run well in DOSBOX, but I would rather have it in Linux.

Thanks again for your help.
 
Old 12-01-2015, 04:19 PM   #4
DrDwayne
Member
 
Registered: May 2010
Location: Wichita
Distribution: Ubuntu Debian
Posts: 155

Original Poster
Rep: Reputation: 4
Hello Dugan,

If I may borrow you one more time. . .

This seems logical to me, but it doesn't work: BCB it will work very similar, but I would have to use a AnsiString with a pointer.

Quote:
void MainWindow:n_pushButton_2_clicked()
{
char linedata[20];
strcpy(linedata,ui->lineEdit->text()) ;
ui->lineEdit->setText(linedata);
}
I am able to get data into the lineEdit with a variable, but can't get data out of the lineedit into a variable.

Do you know of a website that has this kind of info in it?

Seems like "Cntl F-1" doesn't work for help. . .<smile>
 
Old 12-01-2015, 04:25 PM   #5
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,225

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
Stop trying to use the C library with Qt. :P

Try this:

Code:
QString lineData = ui->lineEdit->text();
Or, if you're using C++ 0x or later:

Code:
auto lineData = ui->lineEdit->text();
Quote:
Originally Posted by DrDwayne View Post
Do you know of a website that has this kind of info in it?
http://doc.qt.io/
 
1 members found this post helpful.
Old 12-02-2015, 11:10 AM   #6
DrDwayne
Member
 
Registered: May 2010
Location: Wichita
Distribution: Ubuntu Debian
Posts: 155

Original Poster
Rep: Reputation: 4
You may have hit upon something there. . .

Since I am always trying to use the C library, maybe I have the wrong IDE?

Should I be using something different, that is more in like with what I am use to using?
Something other than QT?
 
Old 12-02-2015, 11:34 AM   #7
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,225

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
Quote:
Originally Posted by drdwayne View Post
should i be using something different, that is more in like with what i am use to using?

Something other than qt?
gtk? Fltk?

Last edited by dugan; 12-02-2015 at 11:40 AM.
 
1 members found this post helpful.
Old 02-05-2016, 03:40 PM   #8
DrDwayne
Member
 
Registered: May 2010
Location: Wichita
Distribution: Ubuntu Debian
Posts: 155

Original Poster
Rep: Reputation: 4
Ok, another question. . .

In Borlands/Embacardero stuff, i use open and close for file manipulations. .
As such:


return(open(filename,O_CREAT|O_BINARY|O_TRUNC,S_IREAD|S_IWRITE));
return(close(filehandle));

QT doesn't recognize "open" or "close".
Nor does it recognize the binary statements:
O_CREAT - create if doesn't exist
O_BINARY - open as a binary file, not ascii
O_TRUNC - truncate size to zero if exists
S_IREAD|S_IWRITE) - Open as read and write.

Thus, I can't find the header for open and close, so none of my open/close statements make any sense to the compiler.

What header should I use? or is "open/close" valid in linux?
 
Old 02-05-2016, 09:38 PM   #9
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 792

Rep: Reputation: 331Reputation: 331Reputation: 331Reputation: 331
Qt is a c++ library so it's best, as dugan pointed out, that you stick with the c++ standard library.
http://www.cplusplus.com/reference/f.../fstream/open/

Also if you are writing Qt applications you can use Qt classes and methods. IMO the Qt docs are excellent:
http://doc.qt.io/qt-5/qfile.html#open
http://doc.qt.io/qt-5/qiodevice.html#OpenModeFlag-enum

Last edited by norobro; 02-05-2016 at 10:46 PM. Reason: fixed link
 
1 members found this post helpful.
Old 02-06-2016, 01:00 AM   #10
a4z
Senior Member
 
Registered: Feb 2009
Posts: 1,727

Rep: Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742
Quote:
Originally Posted by DrDwayne View Post
You may have hit upon something there. . .

Since I am always trying to use the C library, maybe I have the wrong IDE?

Should I be using something different, that is more in like with what I am use to using?
Something other than QT?
http://doc.qt.io/qt-5/gettingstarted.html


gtk is a C library.
but OOP like C with a own set of libraries.
like all tools kits it require some time to get used to it.
but you have to start with the provided documentation and samples provided by the tool kit, no matter if you use Qt gtk, gtk++ fltk fox wxwidgets, .... whatever
 
1 members found this post helpful.
Old 02-06-2016, 01:12 AM   #11
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,624

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
most OS's have the general all purpose IDE "Eclipse" in the repos

QT Creator is nice BUT it mostly is for using the QT image libs and KDE


Eclipse is a "Swiss army knife" of tools
there is also a fork of Eclipse for NVIDIA's CUDA called "nsight"
 
1 members found this post helpful.
Old 02-15-2016, 04:10 PM   #12
Ramurd
Member
 
Registered: Mar 2009
Location: Rotterdam, the Netherlands
Distribution: Slackwarelinux
Posts: 703

Rep: Reputation: 111Reputation: 111
not that I did much in Eclipse, beyond coding in Java; QtCreator is actually a very, very nice IDE to write (portable) C++ GUI code.
So far I have not been able to get write a C GUI-thing in Eclipse;

A nice designer for the layout of the window, buttons and all the fields... Eclipse does have that for Java; but I have not been able to get something similar for C or any other progamming language that Eclipse can help with... Eclipse is a really nice framework; but I tend not to use it for C(++)

but, like all it does take a bit of learning (although, imo, the learning curve is not really steep, especially if you already have some experience in others)
The QT documentation is quite nice, fairly complete and provides examples... not much more than I can wish for.
 
1 members found this post helpful.
Old 02-16-2016, 12:25 AM   #13
a4z
Senior Member
 
Registered: Feb 2009
Posts: 1,727

Rep: Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742
don't use eclipse from some repos, download, extract run it

it does of course not have the GUI interface designer for ..(place gui toolkit here),
but many projects do not use the GUI interface designers anyway
or you desing your interface with ..(place gui toolkit tool here) and do the coding in eclipse.

but of course, Qt creator has, especially for QML, extra tools that can be nice and for working through the tutorials it is excellent.
from point of working with C++ code it's not that feature rich as eclipse, eg spell checking for comments, re-factoring, show implementaion of function in overlay, ... but as said, there is no need to restrict you to one IDE, using CMake they can work pretty nice together
 
1 members found this post helpful.
Old 02-16-2016, 08:05 AM   #14
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Don't use Qt Creator to learn Qt. Every example and help I've received from Digia (original creators of Qt) was code in C++. Look at their examples. The creator makes up this abstract project, and while it's all nice, when you say stuff like "I want to change a button's behavior" all the results I usually find are code examples. (Actually you see a lot of them in Stack OV ...)

When you look at the documentation about a button you see it inherits widget attributes, and from there you can see all the properties and methods each of those support. Stay within the library properties and you'll be fine.

I've used fltk and that works fine too, but it is much more limited and they seemed to have stopped development with it.

I'd start with the Qt hello world example and as others are saying, stay within the Qt library and stop trying to match this all up against Borland which is more than 20? years old.
 
Old 02-16-2016, 09:50 AM   #15
DrDwayne
Member
 
Registered: May 2010
Location: Wichita
Distribution: Ubuntu Debian
Posts: 155

Original Poster
Rep: Reputation: 4
So far, I have been playing around with QT. . .

All my life I have been using Borland products and embarcadero products. . .all for windows. Ever since Turbo C/C++ version 1. from borland.

Most of my code I believe will work, I just need to figure out the classes to convert QT to basic C/C++ and convert back. I also need to figure out some of the idiosyncrasies. between the two C/C++ languages. . .

For example

strncmpi and strcmpi does not seem to exist in linux. So I wrote a simple subroutine to make them compatible for linux

Code:
int comparestrings(char *a,char *b)
 {
  int d,e;
//  char tt[10];
  for(d=0;d<strlen(a);d++)
  {
   if(a[d]==b[d])e=0;
   if(a[d]>b[d])e=1;
   if(a[d]<b[d])e=-1;
   if(e!=0)d=strlen(a)+1;
  }

  return e;
 }
I just need to figure out how to convert in and out of Linux's C/C++ QT, and I will have it made.

Unfortunately, it is rather difficult to find the routines I want over the QT website. . .I am either looking for the
wrong syntax, wrong routine, or something simllar. . . What has helped tremendously, is when folks give me a link to a routine, and I find that the routine wasn't what I was looking for, but SHOULD have been looking for. <Very Big Smile> Then I can kind of go from there.

I am a customer programmer for a large Lumber Co. been there for almost 40 years, and have written their complete accounting system in C/C++. But about 3 years ago, I started playing with Linux. I have been very impressed with what Linux has become. My main operating system is linux now, and I use VMPlayer for my Windows Shell now. Thus I can run 3 or 4 OS's at the same time. I usually have 3 OS's going at once. Linux my main. Windows my 1st. and Linux as my second and "internet surfing" OS. That way I am isolated from the LAN network and the WAN network.

I have a few programs I would like to port over to Linux. They run quite well in WINE, but I would rather have them written in Linux C/C++.

The two have their idiosyncrasies, but it is a opportunity to better myself in Linux. My knowledge of Linux is STILL very naive. I have much to learn. Thus, I have to learn it on the side after my other work is done. As I get older, sometimers sits in... I will sometimes forget what I have learned a year ago, and have to relearn it again, because I never use it. Oh well. . .

I will have to work on building up small subroutines to help me convert some of my programs.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Qt Creator Problem MTK358 Programming 8 06-23-2010 12:18 PM
QT Creator C4C Linux - Newbie 1 12-26-2009 03:37 PM
CD Creator can't see blank CD-R jberkery Red Hat 2 08-17-2006 04:37 PM
gdm creator doralsoral Linux - Software 1 08-20-2004 02:56 AM
help with cd creator creid Linux - Hardware 1 06-14-2004 03:09 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration