I'm using sublime text 3, it has auto indent. It works pretty good, but it uses style different than I preffer. Sublime uses something like that
do
{
/* code */
} while (/* condition */);
int main(int argc, char const *argv[])
{
/* code */
return 0;
}
while I'd prefer something like that
do {
/* code */
} while (/* condition */);
int main(int argc, char const *argv[]) {
/* code */
return 0;
}
Is there a way to change sublime's indent style?
You can after tab press ctrl+j.
I trying modify about indent the configure files, but useless.
If anyone know how to modify, please tell me :D
Change the snippets in the "C++.sublime-package" in the Packages folder.
In Linux:
/opt/sublime_text/Packages
In Windows:
C:\Users\yourUsername\AppData\Roaming\Sublime Text 2\Packages
Or in Sublime Preferences > Browse Packages... Then edit the language you want.
PS: C and C++ are in the same folder "C++"
Related
On the app start i have a console window, so how not to show it?
(Without Using WinMain! Because its parameters don't match to QApp)
My main.cpp code is:
int main(int _nArgCount, char * _pArgValues[]) {
QApplication app(_nArgCount, _pArgValues);
//QMLblock
QString strQmlPath = "qrc:qml/main.qml";
QQmlApplicationEngine engine;
QQmlComponent component(&engine, QUrl(strQmlPath));
if (component.status() == QQmlComponent::Error) {
qDebug()<<"Error:"<<component.errorString();
return app.exec();
}
Gui gui(component);
gui.recreateGui();
//state machine block
QStateMachine machine;
....
....
....
return app.exec();
}
When I pass the same unicode argument from QT5->Projects->Run the app works, but fails if passed as an argument directly to the exe. The arguments are being passed from an webpage encoded using encodeURIComponent in javascript.
The code is:
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
if(a.arguments().count() < 2)
{
qFatal("No argument provided");
return EXIT_FAILURE;
}
QStringList args = a.arguments().at(1).split("####");
QString param1 = args.at(1);
QUrl downurl = QUrl::fromPercentEncoding(param.toLocal8Bit());
..........
}
Figured this out, using param.toUtf8() in the above code fixes this.
The question is very simple. Is it possible to show QDialog or QMessageBox without creating a tab in the task bar for it? I tried using exec(), show(), changing value of modal, but the tab is always on.
You need to specify parent window for the QMessageBox:
QApplication a(argc, argv);
qt_test_dialog w;
w.show();
// with additional button
// QMessageBox box(QMessageBox::Information, "Title", "Hello there!", QMessageBox::Ok);
// without additional button!
QMessageBox box(QMessageBox::Information, "Title", "Hello there!", QMessageBox::Ok, &w);
Or simply:
QMessageBox box(&w);
box.setText("Hello");
box.exec();
Note that parent parameter can even be empty QWidget:
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
// plain wrong (you will not be able to exit application) - but it demonstrates
// the case
QMessageBox box(new QWidget());
box.setText("Hello");
box.exec();
return a.exec();
}
I am writing a small GUI application using Haskell's gtk2hs library and am currently working with the multiline text boxes within it. I have a function which I want to run when the user makes changes to the text within the text box, but don't want them to have to click a button to activate it.
Furthermore, because it is a rather intrusive and processing intensive function (It draws graphics, loads files etc.), I would like it to fire not whenever a user makes any change (which could probably be done with the bufferChanged signal in text buffer I'm guessing?) but when they stop for a few seconds in between changes.
Basically I am wondering if there is something in gtk which is analogous to the way range widgets can have their update policy set to continuous or delayed, but for text boxes
I don't know anything of the Haskell bindings but in plain C it is quite easy to implement by leveraging a timeout GSource.
#include <gtk/gtk.h>
static guint source_id = 0;
static gboolean do_stuff(gpointer user_data)
{
g_print("doing stuff...\n");
return FALSE;
}
static void postpone(void)
{
if (source_id > 0)
g_source_remove(source_id);
source_id = g_timeout_add(1000, do_stuff, NULL);
}
int main(int argc, char **argv)
{
GtkWidget *window, *text_view;
GtkTextBuffer *text_buffer;
gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(window, "delete-event", G_CALLBACK(gtk_main_quit), NULL);
text_view = gtk_text_view_new();
gtk_container_add(GTK_CONTAINER(window), text_view);
text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_view));
g_signal_connect(text_buffer, "changed", G_CALLBACK(postpone), NULL);
gtk_widget_show_all(window);
gtk_main();
return 0;
}
The issue of quitting the TextView before the timeout has elapsed is still open though.
int main( int argc,
char *argv[] )
{
GtkWidget *window;
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_show (window);
gtk_main ();
return 0;
}
The above is just a empty winform,I want to output dynamic information in it(not editable),
how should I do that?
You need a GtkTextView which you can set to be not editable. I suggest you look at this excellent GTK tutorial which explains what widgets are available in GTK and how to put them together, accompanied by lots of example code.