2

I have QT version 4.5.3. Does it support @import()? I'm trying to import another css file into my css file I have cssA.css and cssB.css in the same folder. I import cssA.css in cssB.css by using @import(:/cssA.css); but it doesn't seem to work. Can anybody tell me what's wrong?

3 Answers 3

2

I didn't find a good answer myself, so I manually concatenate multiple stylesheets to emulate 'importing'. For example, in C++:

QApplication a(argc, argv);
// Load stylesheets
QString finalCss;
QFile baseCssFile(":/Common/Theme.css");
if (baseCssFile.open(QIODevice::ReadOnly | QIODevice::Text))
{
    finalCss.append(baseCssFile.readAll().data());
}
QFile cssFile(":/CustomApp/CustomApp.css");
if (cssFile.open(QIODevice::ReadOnly | QIODevice::Text))
{
    finalCss.append(cssFile.readAll().data());
}
a.setStyleSheet(finalCss);
Sign up to request clarification or add additional context in comments.

1 Comment

This is the only sane approach. Since Qt currently provides no support for importing one stylesheet into another, the onus is squarely on developers to manually do so. </forlorn_sigh>
0

Can you please try @import 'color_controls.css';

1 Comment

QSS ≠ CSS. Sadly, Qt provides no support for importing one stylesheet into another. See this open Qt feature request for further discussion.
0

I would advise taking a look at this website: Stylesheets

Syntax: @import ""; or @import url("");

For example:

@import "commonstylesheet.css";

1 Comment

QSS ≠ CSS. Sadly, Qt provides no support for importing one stylesheet into another. See this open Qt feature request for further discussion.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.